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;