From d51db2228b573db7846ad525a2f0dd47181395a7 Mon Sep 17 00:00:00 2001 From: Zachary Dremann Date: Wed, 22 May 2024 20:34:04 -0400 Subject: [PATCH] Add roaring64_bitmap_clear function --- include/roaring/roaring64.h | 5 +++++ src/roaring64.c | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/include/roaring/roaring64.h b/include/roaring/roaring64.h index edf1f1b77..c71bccb91 100644 --- a/include/roaring/roaring64.h +++ b/include/roaring/roaring64.h @@ -202,6 +202,11 @@ void roaring64_bitmap_remove_range(roaring64_bitmap_t *r, uint64_t min, void roaring64_bitmap_remove_range_closed(roaring64_bitmap_t *r, uint64_t min, uint64_t max); +/** + * Empties the bitmap. + */ +void roaring64_bitmap_clear(roaring64_bitmap_t *r); + /** * Returns true if the provided value is present. */ diff --git a/src/roaring64.c b/src/roaring64.c index e09136024..b10bf4594 100644 --- a/src/roaring64.c +++ b/src/roaring64.c @@ -707,6 +707,10 @@ void roaring64_bitmap_remove_range_closed(roaring64_bitmap_t *r, uint64_t min, remove_range_closed_at(art, max_high48, 0, max_low16); } +void roaring64_bitmap_clear(roaring64_bitmap_t *r) { + roaring64_bitmap_remove_range_closed(r, 0, UINT64_MAX); +} + uint64_t roaring64_bitmap_get_cardinality(const roaring64_bitmap_t *r) { art_iterator_t it = art_init_iterator(&r->art, /*first=*/true); uint64_t cardinality = 0;