4 #ifndef INCLUDE_ROARING_HH_
5 #define INCLUDE_ROARING_HH_
9 #include <initializer_list>
15 #if !defined(ROARING_EXCEPTIONS)
17 #ifndef __cpp_exceptions
18 #error "__cpp_exceptions should be defined"
21 #define ROARING_EXCEPTIONS 1
23 #define ROARING_EXCEPTIONS 0
27 #ifndef ROARING_TERMINATE
28 #if ROARING_EXCEPTIONS
29 #define ROARING_TERMINATE(_s) throw std::runtime_error(_s)
31 #define ROARING_TERMINATE(_s) std::terminate()
35 #define ROARING_API_NOT_IN_GLOBAL_NAMESPACE
37 #undef ROARING_API_NOT_IN_GLOBAL_NAMESPACE
39 #include <roaring/roaring_array.h>
95 addMany(l.size(), l.begin());
142 for (
size_t i = 0; i < n; i++) {
143 ans.
add(va_arg(vl, uint32_t));
193 ans.
addMany(l.size(), l.begin());
214 void addRange(
const uint64_t min,
const uint64_t max) noexcept {
228 void addMany(
size_t n_args,
const uint32_t *vals) noexcept {
321 const uint32_t y)
const noexcept {
396 ((uint64_t)(std::numeric_limits<uint32_t>::max)()) + 1;
425 size_t limit)
const noexcept {
440 void flip(uint64_t range_start, uint64_t range_end) noexcept {
448 void flipClosed(uint32_t range_start, uint32_t range_end) noexcept {
488 void iterate(api::roaring_iterator iterator,
void *ptr)
const {
500 bool select(uint32_t rnk, uint32_t *element)
const noexcept {
559 uint64_t
rank(uint32_t x)
const noexcept {
568 void rank_many(
const uint32_t *begin,
const uint32_t *end,
569 uint64_t *ans)
const noexcept {
623 size_t write(
char *buf,
bool portable =
true) const noexcept {
648 roaring_bitmap_t *r =
681 roaring_bitmap_t *r =
710 const roaring_bitmap_t *s =
725 const roaring_bitmap_t *s =
825 char first_char =
'{';
829 [](uint32_t value,
void *inner_iter_data) ->
bool {
830 ((iter_data *)inner_iter_data)->str +=
831 ((iter_data *)inner_iter_data)->first_char;
832 ((iter_data *)inner_iter_data)->str +=
833 std::to_string(value);
834 ((iter_data *)inner_iter_data)->first_char =
',';
837 (
void *)&outer_iter_data);
839 outer_iter_data.str =
'{';
840 outer_iter_data.str +=
'}';
841 return outer_iter_data.str;
857 const roaring_bitmap_t **x = (
const roaring_bitmap_t **)roaring_malloc(
858 n *
sizeof(roaring_bitmap_t *));
862 for (
size_t k = 0; k < n; ++k) x[k] = &inputs[k]->
roaring;
879 if (!(
roaring.high_low_container.flags & ROARING_FLAG_FROZEN)) {
889 (roaring_bitmap_t *)((
char *)
890 roaring.high_low_container.containers -
891 sizeof(roaring_bitmap_t)));
932 bool exhausted =
false) {
935 i.container_index = INT32_MAX;
937 i.current_value = UINT32_MAX;
949 if (!i.has_value)
return false;
950 if (!o.
i.has_value)
return true;
951 return i.current_value < *o;
955 if (!o.
i.has_value)
return true;
956 if (!i.has_value)
return false;
957 return i.current_value <= *o;
961 if (!o.
i.has_value)
return false;
962 if (!i.has_value)
return true;
963 return i.current_value > *o;
967 if (!i.has_value)
return true;
968 if (!o.
i.has_value)
return false;
969 return i.current_value >= *o;
1008 return i.current_value == *o && i.has_value == o.
i.has_value;
1012 return i.current_value != *o || i.has_value != o.
i.has_value;
BulkContext(const BulkContext &)=delete
BulkContext(BulkContext &&) noexcept=default
api::roaring_bulk_context_t roaring_bitmap_bulk_context_t
BulkContext & operator=(const BulkContext &)=delete
bool move_equalorlarger(value_type val)
type_of_iterator & operator--()
bool operator>=(const type_of_iterator &o) const
bool operator<=(const type_of_iterator &o) const
type_of_iterator & operator++()
bool operator==(const RoaringSetBitBiDirectionalIterator &o) const
api::roaring_uint32_iterator_t i
CROARING_DEPRECATED void equalorlarger(uint32_t val)
bool operator<(const type_of_iterator &o) const
value_type operator*() const
type_of_iterator operator--(int)
uint32_t & reference_type
RoaringSetBitBiDirectionalIterator type_of_iterator
bool operator>(const type_of_iterator &o) const
std::bidirectional_iterator_tag iterator_category
RoaringSetBitBiDirectionalIterator(const Roaring &parent, bool exhausted=false)
type_of_iterator operator++(int)
bool operator!=(const RoaringSetBitBiDirectionalIterator &o) const
Roaring operator-(const Roaring &o) const
Roaring(roaring_bitmap_t *s) noexcept
static Roaring fastunion(size_t n, const Roaring **inputs)
size_t getFrozenSizeInBytes() const noexcept
size_t shrinkToFit() noexcept
uint64_t xor_cardinality(const Roaring &r) const noexcept
static Roaring readSafe(const char *buf, size_t maxbytes)
bool addChecked(uint32_t x) noexcept
uint64_t rank(uint32_t x) const noexcept
Roaring & operator=(std::initializer_list< uint32_t > l)
void addRange(const uint64_t min, const uint64_t max) noexcept
size_t write(char *buf, bool portable=true) const noexcept
void addRangeClosed(const uint32_t min, const uint32_t max) noexcept
uint64_t or_cardinality(const Roaring &r) const noexcept
Roaring(Roaring &&r) noexcept
static Roaring bitmapOfList(std::initializer_list< uint32_t > l)
static Roaring read(const char *buf, bool portable=true)
bool runOptimize() noexcept
Roaring operator|(const Roaring &o) const
uint64_t cardinality() const noexcept
bool containsRange(const uint64_t x, const uint64_t y) const noexcept
bool removeRunCompression() noexcept
void add(uint32_t x) noexcept
bool containsRangeClosed(const uint32_t x, const uint32_t y) const noexcept
static Roaring bitmapOf(size_t n,...)
void addBulk(BulkContext &context, uint32_t x) noexcept
void addMany(size_t n_args, const uint32_t *vals) noexcept
const_iterator begin() const
bool isFull() const noexcept
bool intersect(const Roaring &r) const noexcept
std::string toString() const noexcept
static const Roaring frozenView(const char *buf, size_t length)
Roaring(size_t n, const uint32_t *data)
bool containsBulk(BulkContext &context, uint32_t x) const noexcept
RoaringSetBitBiDirectionalIterator const_iterator
Roaring & operator^=(const Roaring &r) noexcept
bool operator==(const Roaring &r) const noexcept
void flipClosed(uint32_t range_start, uint32_t range_end) noexcept
void writeFrozen(char *buf) const noexcept
bool removeChecked(uint32_t x) noexcept
Roaring & operator=(const Roaring &r)
Roaring operator&(const Roaring &o) const
uint64_t andnot_cardinality(const Roaring &r) const noexcept
bool contains(uint32_t x) const noexcept
static const Roaring portableDeserializeFrozen(const char *buf)
bool getCopyOnWrite() const noexcept
void rangeUint32Array(uint32_t *ans, size_t offset, size_t limit) const noexcept
Roaring & operator&=(const Roaring &r) noexcept
uint64_t and_cardinality(const Roaring &r) const noexcept
size_t getSizeInBytes(bool portable=true) const noexcept
void flip(uint64_t range_start, uint64_t range_end) noexcept
void iterate(api::roaring_iterator iterator, void *ptr) const
Roaring & operator=(Roaring &&r) noexcept
void rank_many(const uint32_t *begin, const uint32_t *end, uint64_t *ans) const noexcept
Roaring(std::initializer_list< uint32_t > l)
void toUint32Array(uint32_t *ans) const noexcept
void remove(uint32_t x) noexcept
bool isEmpty() const noexcept
void removeRange(uint64_t min, uint64_t max) noexcept
Roaring & operator|=(const Roaring &r) noexcept
Roaring operator^(const Roaring &o) const
void setCopyOnWrite(bool val) noexcept
Roaring & operator-=(const Roaring &r) noexcept
void printf() const noexcept
uint32_t minimum() const noexcept
double jaccard_index(const Roaring &r) const noexcept
RoaringSetBitBiDirectionalIterator const_bidirectional_iterator
bool isSubset(const Roaring &r) const noexcept
bool select(uint32_t rnk, uint32_t *element) const noexcept
int64_t getIndex(uint32_t x) const noexcept
void swap(Roaring &r) noexcept
Roaring(const Roaring &r)
uint32_t maximum() const noexcept
bool isStrictSubset(const Roaring &r) const noexcept
const_iterator & end() const
void removeRangeClosed(uint32_t min, uint32_t max) noexcept
roaring_bitmap_t * roaring_bitmap_and(const roaring_bitmap_t *r1, const roaring_bitmap_t *r2)
bool roaring_bitmap_select(const roaring_bitmap_t *r, uint32_t rank, uint32_t *element)
roaring_bitmap_t * roaring_bitmap_portable_deserialize_safe(const char *buf, size_t maxbytes)
bool roaring_bitmap_add_checked(roaring_bitmap_t *r, uint32_t x)
void roaring_bitmap_andnot_inplace(roaring_bitmap_t *r1, const roaring_bitmap_t *r2)
void roaring_bitmap_add_range_closed(roaring_bitmap_t *r, uint32_t min, uint32_t max)
bool roaring_bitmap_contains_bulk(const roaring_bitmap_t *r, roaring_bulk_context_t *context, uint32_t val)
size_t roaring_bitmap_portable_serialize(const roaring_bitmap_t *r, char *buf)
bool roaring_bitmap_equals(const roaring_bitmap_t *r1, const roaring_bitmap_t *r2)
void roaring_bitmap_flip_inplace(roaring_bitmap_t *r1, uint64_t range_start, uint64_t range_end)
size_t roaring_bitmap_shrink_to_fit(roaring_bitmap_t *r)
roaring_bitmap_t * roaring_bitmap_or_many(size_t number, const roaring_bitmap_t **rs)
void roaring_bitmap_clear(roaring_bitmap_t *r)
bool roaring_bitmap_intersect(const roaring_bitmap_t *r1, const roaring_bitmap_t *r2)
bool roaring_bitmap_run_optimize(roaring_bitmap_t *r)
void roaring_bitmap_and_inplace(roaring_bitmap_t *r1, const roaring_bitmap_t *r2)
uint64_t roaring_bitmap_or_cardinality(const roaring_bitmap_t *r1, const roaring_bitmap_t *r2)
void roaring_iterator_init(const roaring_bitmap_t *r, roaring_uint32_iterator_t *newit)
size_t roaring_bitmap_frozen_size_in_bytes(const roaring_bitmap_t *r)
bool roaring_bitmap_range_uint32_array(const roaring_bitmap_t *r, size_t offset, size_t limit, uint32_t *ans)
bool roaring_bitmap_get_copy_on_write(const roaring_bitmap_t *r)
void roaring_bitmap_to_uint32_array(const roaring_bitmap_t *r, uint32_t *ans)
bool roaring_bitmap_overwrite(roaring_bitmap_t *dest, const roaring_bitmap_t *src)
void roaring_bitmap_xor_inplace(roaring_bitmap_t *r1, const roaring_bitmap_t *r2)
bool roaring_uint32_iterator_move_equalorlarger(roaring_uint32_iterator_t *it, uint32_t val)
roaring_bitmap_t * roaring_bitmap_or(const roaring_bitmap_t *r1, const roaring_bitmap_t *r2)
double roaring_bitmap_jaccard_index(const roaring_bitmap_t *r1, const roaring_bitmap_t *r2)
size_t roaring_bitmap_size_in_bytes(const roaring_bitmap_t *r)
bool roaring_uint32_iterator_previous(roaring_uint32_iterator_t *it)
bool roaring_bitmap_remove_run_compression(roaring_bitmap_t *r)
bool roaring_iterate(const roaring_bitmap_t *r, roaring_iterator iterator, void *ptr)
void roaring_bitmap_init_cleared(roaring_bitmap_t *r)
void roaring_bitmap_add_bulk(roaring_bitmap_t *r, roaring_bulk_context_t *context, uint32_t val)
void roaring_bitmap_frozen_serialize(const roaring_bitmap_t *r, char *buf)
void roaring_bitmap_remove_range(roaring_bitmap_t *r, uint64_t min, uint64_t max)
void roaring_bitmap_add_many(roaring_bitmap_t *r, size_t n_args, const uint32_t *vals)
bool roaring_bitmap_contains_range(const roaring_bitmap_t *r, uint64_t range_start, uint64_t range_end)
roaring_bitmap_t * roaring_bitmap_deserialize(const void *buf)
bool roaring_bitmap_is_empty(const roaring_bitmap_t *r)
roaring_bitmap_t * roaring_bitmap_portable_deserialize_frozen(const char *buf)
void roaring_bitmap_free(const roaring_bitmap_t *r)
bool roaring_bitmap_contains(const roaring_bitmap_t *r, uint32_t val)
void roaring_bitmap_remove(roaring_bitmap_t *r, uint32_t x)
void roaring_bitmap_set_copy_on_write(roaring_bitmap_t *r, bool cow)
void roaring_bitmap_remove_range_closed(roaring_bitmap_t *r, uint32_t min, uint32_t max)
const roaring_bitmap_t * roaring_bitmap_frozen_view(const char *buf, size_t length)
bool roaring_bitmap_is_strict_subset(const roaring_bitmap_t *r1, const roaring_bitmap_t *r2)
roaring_bitmap_t * roaring_bitmap_portable_deserialize(const char *buf)
struct roaring_bitmap_s roaring_bitmap_t
uint64_t roaring_bitmap_xor_cardinality(const roaring_bitmap_t *r1, const roaring_bitmap_t *r2)
uint64_t roaring_bitmap_andnot_cardinality(const roaring_bitmap_t *r1, const roaring_bitmap_t *r2)
size_t roaring_bitmap_portable_size_in_bytes(const roaring_bitmap_t *r)
bool roaring_bitmap_is_subset(const roaring_bitmap_t *r1, const roaring_bitmap_t *r2)
void roaring_bitmap_rank_many(const roaring_bitmap_t *r, const uint32_t *begin, const uint32_t *end, uint64_t *ans)
roaring_bitmap_t * roaring_bitmap_xor(const roaring_bitmap_t *r1, const roaring_bitmap_t *r2)
void roaring_bitmap_or_inplace(roaring_bitmap_t *r1, const roaring_bitmap_t *r2)
uint64_t roaring_bitmap_rank(const roaring_bitmap_t *r, uint32_t x)
uint32_t roaring_bitmap_maximum(const roaring_bitmap_t *r)
void roaring_bitmap_add_range(roaring_bitmap_t *r, uint64_t min, uint64_t max)
void roaring_bitmap_flip_inplace_closed(roaring_bitmap_t *r1, uint32_t range_start, uint32_t range_end)
int64_t roaring_bitmap_get_index(const roaring_bitmap_t *r, uint32_t x)
uint64_t roaring_bitmap_get_cardinality(const roaring_bitmap_t *r)
size_t roaring_bitmap_serialize(const roaring_bitmap_t *r, char *buf)
uint64_t roaring_bitmap_and_cardinality(const roaring_bitmap_t *r1, const roaring_bitmap_t *r2)
roaring_bitmap_t * roaring_bitmap_andnot(const roaring_bitmap_t *r1, const roaring_bitmap_t *r2)
struct roaring_bulk_context_s roaring_bulk_context_t
struct roaring_uint32_iterator_s roaring_uint32_iterator_t
bool roaring_bitmap_contains_range_closed(const roaring_bitmap_t *r, uint32_t range_start, uint32_t range_end)
bool roaring_bitmap_remove_checked(roaring_bitmap_t *r, uint32_t x)
void roaring_bitmap_printf(const roaring_bitmap_t *r)
bool roaring_uint32_iterator_advance(roaring_uint32_iterator_t *it)
uint32_t roaring_bitmap_minimum(const roaring_bitmap_t *r)
void roaring_bitmap_add(roaring_bitmap_t *r, uint32_t x)
#define ROARING_TERMINATE(_s)