CRoaring  4.2.1
Roaring bitmaps in C (and C++)
roaring64.h
Go to the documentation of this file.
1 #ifndef ROARING64_H
2 #define ROARING64_H
3 
4 #include <stdbool.h>
5 #include <stddef.h>
6 #include <stdint.h>
7 
8 #include <roaring/memory.h>
9 #include <roaring/portability.h>
10 #include <roaring/roaring.h>
11 #include <roaring/roaring_types.h>
12 
13 #ifdef __cplusplus
14 extern "C" {
15 namespace roaring {
16 namespace api {
17 #endif
18 
19 typedef struct roaring64_bitmap_s roaring64_bitmap_t;
20 typedef struct roaring64_leaf_s roaring64_leaf_t;
21 typedef struct roaring64_iterator_s roaring64_iterator_t;
22 
34 typedef struct roaring64_bulk_context_s {
35  uint8_t high_bytes[6];
38 
45 
50 
55  const uint64_t *vals);
56 
57 #ifdef __cplusplus
64 // Use an immediately invoked closure, capturing by reference
65 // (in case __VA_ARGS__ refers to context outside the closure)
66 // Include a 0 at the beginning of the array to make the array length > 0
67 // (zero sized arrays are not valid in standard c/c++)
68 #define roaring64_bitmap_from(...) \
69  [&]() { \
70  const uint64_t roaring64_bitmap_from_array[] = {0, __VA_ARGS__}; \
71  return roaring64_bitmap_of_ptr( \
72  (sizeof(roaring64_bitmap_from_array) / \
73  sizeof(roaring64_bitmap_from_array[0])) - \
74  1, \
75  &roaring64_bitmap_from_array[1]); \
76  }()
77 #else
84 // While __VA_ARGS__ occurs twice in expansion, one of the times is in a sizeof
85 // expression, which is an unevaluated context, so it's even safe in the case
86 // where expressions passed have side effects (roaring64_bitmap_from(my_func(),
87 // ++i))
88 // Include a 0 at the beginning of the array to make the array length > 0
89 // (zero sized arrays are not valid in standard c/c++)
90 #define roaring64_bitmap_from(...) \
91  roaring64_bitmap_of_ptr( \
92  (sizeof((const uint64_t[]){0, __VA_ARGS__}) / sizeof(uint64_t)) - 1, \
93  &((const uint64_t[]){0, __VA_ARGS__})[1])
94 #endif
95 
103 
109  uint64_t step);
110 
115 
121 
137  roaring64_bulk_context_t *context, uint64_t val);
138 
148  const uint64_t *vals);
149 
154  uint64_t max);
155 
160  uint64_t max);
161 
166 
172 
188  roaring64_bulk_context_t *context,
189  uint64_t val);
190 
200  const uint64_t *vals);
201 
206  uint64_t max);
207 
212  uint64_t max);
213 
218 
222 bool roaring64_bitmap_contains(const roaring64_bitmap_t *r, uint64_t val);
223 
228  uint64_t max);
229 
246  roaring64_bulk_context_t *context,
247  uint64_t val);
248 
255 bool roaring64_bitmap_select(const roaring64_bitmap_t *r, uint64_t rank,
256  uint64_t *element);
257 
268 uint64_t roaring64_bitmap_rank(const roaring64_bitmap_t *r, uint64_t val);
269 
275 bool roaring64_bitmap_get_index(const roaring64_bitmap_t *r, uint64_t val,
276  uint64_t *out_index);
277 
282 
287  uint64_t min, uint64_t max);
288 
293  uint64_t min, uint64_t max);
294 
299 
304 
309 
314 
320  roaring64_statistics_t *stat);
321 
334  const char **reason);
335 
340  const roaring64_bitmap_t *r2);
341 
346  const roaring64_bitmap_t *r2);
347 
353  const roaring64_bitmap_t *r2);
354 
365  const roaring64_bitmap_t *r2);
366 
371  const roaring64_bitmap_t *r2);
372 
381  const roaring64_bitmap_t *r2);
382 
387  const roaring64_bitmap_t *r2);
388 
393  uint64_t min, uint64_t max);
394 
402  const roaring64_bitmap_t *r2);
403 
409  const roaring64_bitmap_t *r2);
410 
415  const roaring64_bitmap_t *r2);
416 
421  const roaring64_bitmap_t *r2);
422 
428  const roaring64_bitmap_t *r2);
429 
434  const roaring64_bitmap_t *r2);
435 
441  const roaring64_bitmap_t *r2);
442 
448  const roaring64_bitmap_t *r2);
449 
454  const roaring64_bitmap_t *r2);
455 
461  const roaring64_bitmap_t *r2);
462 
469  uint64_t min, uint64_t max);
470 
477  uint64_t min, uint64_t max);
478 
485  uint64_t max);
492  uint64_t max);
500 
520  char *buf);
529  size_t maxbytes);
530 
565  size_t maxbytes);
566 
581  roaring_iterator64 iterator, void *ptr);
582 
592  uint64_t *out);
593 
603 
613  const roaring64_bitmap_t *r);
614 
621 
628 
634 
639 
645 
651 
662 
673 
682  uint64_t val);
683 
691 uint64_t roaring64_iterator_read(roaring64_iterator_t *it, uint64_t *buf,
692  uint64_t count);
693 
694 #ifdef __cplusplus
695 } // extern "C"
696 } // namespace roaring
697 } // namespace api
698 #endif
699 
700 #endif /* ROARING64_H */
roaring64_bitmap_t * roaring64_bitmap_move_from_roaring32(roaring_bitmap_t *r)
uint64_t roaring64_bitmap_or_cardinality(const roaring64_bitmap_t *r1, const roaring64_bitmap_t *r2)
void roaring64_bitmap_add_many(roaring64_bitmap_t *r, size_t n_args, const uint64_t *vals)
roaring64_bitmap_t * roaring64_bitmap_and(const roaring64_bitmap_t *r1, const roaring64_bitmap_t *r2)
bool roaring64_bitmap_intersect(const roaring64_bitmap_t *r1, const roaring64_bitmap_t *r2)
void roaring64_bitmap_remove(roaring64_bitmap_t *r, uint64_t val)
void roaring64_bitmap_xor_inplace(roaring64_bitmap_t *r1, const roaring64_bitmap_t *r2)
roaring64_iterator_t * roaring64_iterator_create(const roaring64_bitmap_t *r)
roaring64_bitmap_t * roaring64_bitmap_or(const roaring64_bitmap_t *r1, const roaring64_bitmap_t *r2)
void roaring64_bitmap_remove_many(roaring64_bitmap_t *r, size_t n_args, const uint64_t *vals)
roaring64_bitmap_t * roaring64_bitmap_copy(const roaring64_bitmap_t *r)
roaring64_bitmap_t * roaring64_bitmap_andnot(const roaring64_bitmap_t *r1, const roaring64_bitmap_t *r2)
uint64_t roaring64_iterator_value(const roaring64_iterator_t *it)
void roaring64_bitmap_add_range_closed(roaring64_bitmap_t *r, uint64_t min, uint64_t max)
uint64_t roaring64_bitmap_andnot_cardinality(const roaring64_bitmap_t *r1, const roaring64_bitmap_t *r2)
roaring64_iterator_t * roaring64_iterator_create_last(const roaring64_bitmap_t *r)
void roaring64_iterator_reinit_last(const roaring64_bitmap_t *r, roaring64_iterator_t *it)
void roaring64_bitmap_flip_closed_inplace(roaring64_bitmap_t *r, uint64_t min, uint64_t max)
bool roaring64_bitmap_equals(const roaring64_bitmap_t *r1, const roaring64_bitmap_t *r2)
roaring64_bitmap_t * roaring64_bitmap_flip(const roaring64_bitmap_t *r, uint64_t min, uint64_t max)
roaring64_bitmap_t * roaring64_bitmap_from_range(uint64_t min, uint64_t max, uint64_t step)
bool roaring64_bitmap_get_index(const roaring64_bitmap_t *r, uint64_t val, uint64_t *out_index)
size_t roaring64_bitmap_portable_size_in_bytes(const roaring64_bitmap_t *r)
bool roaring64_bitmap_run_optimize(roaring64_bitmap_t *r)
bool roaring64_bitmap_add_checked(roaring64_bitmap_t *r, uint64_t val)
void roaring64_bitmap_add(roaring64_bitmap_t *r, uint64_t val)
bool roaring64_bitmap_intersect_with_range(const roaring64_bitmap_t *r, uint64_t min, uint64_t max)
uint64_t roaring64_bitmap_range_cardinality(const roaring64_bitmap_t *r, uint64_t min, uint64_t max)
bool roaring64_iterator_advance(roaring64_iterator_t *it)
bool roaring64_bitmap_iterate(const roaring64_bitmap_t *r, roaring_iterator64 iterator, void *ptr)
bool roaring64_bitmap_contains_bulk(const roaring64_bitmap_t *r, roaring64_bulk_context_t *context, uint64_t val)
struct roaring64_iterator_s roaring64_iterator_t
Definition: roaring64.h:21
roaring64_bitmap_t * roaring64_bitmap_flip_closed(const roaring64_bitmap_t *r, uint64_t min, uint64_t max)
void roaring64_bitmap_flip_inplace(roaring64_bitmap_t *r, uint64_t min, uint64_t max)
roaring64_bitmap_t * roaring64_bitmap_create(void)
void roaring64_bitmap_statistics(const roaring64_bitmap_t *r, roaring64_statistics_t *stat)
void roaring64_bitmap_andnot_inplace(roaring64_bitmap_t *r1, const roaring64_bitmap_t *r2)
roaring64_bitmap_t * roaring64_bitmap_of_ptr(size_t n_args, const uint64_t *vals)
bool roaring64_bitmap_internal_validate(const roaring64_bitmap_t *r, const char **reason)
void roaring64_bitmap_remove_range_closed(roaring64_bitmap_t *r, uint64_t min, uint64_t max)
uint64_t roaring64_bitmap_range_closed_cardinality(const roaring64_bitmap_t *r, uint64_t min, uint64_t max)
uint64_t roaring64_bitmap_and_cardinality(const roaring64_bitmap_t *r1, const roaring64_bitmap_t *r2)
struct roaring64_bitmap_s roaring64_bitmap_t
Definition: roaring64.h:19
void roaring64_bitmap_remove_range(roaring64_bitmap_t *r, uint64_t min, uint64_t max)
void roaring64_bitmap_add_bulk(roaring64_bitmap_t *r, roaring64_bulk_context_t *context, uint64_t val)
bool roaring64_bitmap_is_strict_subset(const roaring64_bitmap_t *r1, const roaring64_bitmap_t *r2)
void roaring64_bitmap_remove_bulk(roaring64_bitmap_t *r, roaring64_bulk_context_t *context, uint64_t val)
size_t roaring64_bitmap_portable_serialize(const roaring64_bitmap_t *r, char *buf)
roaring64_bitmap_t * roaring64_bitmap_portable_deserialize_safe(const char *buf, size_t maxbytes)
bool roaring64_bitmap_contains(const roaring64_bitmap_t *r, uint64_t val)
void roaring64_bitmap_add_range(roaring64_bitmap_t *r, uint64_t min, uint64_t max)
size_t roaring64_bitmap_portable_deserialize_size(const char *buf, size_t maxbytes)
bool roaring64_iterator_move_equalorlarger(roaring64_iterator_t *it, uint64_t val)
bool roaring64_iterator_has_value(const roaring64_iterator_t *it)
bool roaring64_iterator_previous(roaring64_iterator_t *it)
uint64_t roaring64_bitmap_rank(const roaring64_bitmap_t *r, uint64_t val)
void roaring64_bitmap_to_uint64_array(const roaring64_bitmap_t *r, uint64_t *out)
uint64_t roaring64_bitmap_maximum(const roaring64_bitmap_t *r)
void roaring64_iterator_reinit(const roaring64_bitmap_t *r, roaring64_iterator_t *it)
void roaring64_iterator_free(roaring64_iterator_t *it)
void roaring64_bitmap_and_inplace(roaring64_bitmap_t *r1, const roaring64_bitmap_t *r2)
roaring64_bitmap_t * roaring64_bitmap_xor(const roaring64_bitmap_t *r1, const roaring64_bitmap_t *r2)
bool roaring64_bitmap_contains_range(const roaring64_bitmap_t *r, uint64_t min, uint64_t max)
uint64_t roaring64_iterator_read(roaring64_iterator_t *it, uint64_t *buf, uint64_t count)
struct roaring64_leaf_s roaring64_leaf_t
Definition: roaring64.h:20
bool roaring64_bitmap_select(const roaring64_bitmap_t *r, uint64_t rank, uint64_t *element)
bool roaring64_bitmap_is_subset(const roaring64_bitmap_t *r1, const roaring64_bitmap_t *r2)
uint64_t roaring64_bitmap_xor_cardinality(const roaring64_bitmap_t *r1, const roaring64_bitmap_t *r2)
uint64_t roaring64_bitmap_minimum(const roaring64_bitmap_t *r)
void roaring64_bitmap_free(roaring64_bitmap_t *r)
double roaring64_bitmap_jaccard_index(const roaring64_bitmap_t *r1, const roaring64_bitmap_t *r2)
uint64_t roaring64_bitmap_get_cardinality(const roaring64_bitmap_t *r)
struct roaring64_bulk_context_s roaring64_bulk_context_t
roaring64_iterator_t * roaring64_iterator_copy(const roaring64_iterator_t *it)
void roaring64_bitmap_or_inplace(roaring64_bitmap_t *r1, const roaring64_bitmap_t *r2)
bool roaring64_bitmap_is_empty(const roaring64_bitmap_t *r)
bool roaring64_bitmap_remove_checked(roaring64_bitmap_t *r, uint64_t val)
void roaring64_bitmap_clear(roaring64_bitmap_t *r)
roaring64_leaf_t * leaf
Definition: roaring64.h:36