1pub const ROARING_VERSION: &[u8; 6] = b"4.4.1\0";
4pub const ROARING_VERSION_MAJOR: _bindgen_ty_1 = 4;
5pub const ROARING_VERSION_MINOR: _bindgen_ty_1 = 4;
6pub const ROARING_VERSION_REVISION: _bindgen_ty_1 = 1;
7pub type _bindgen_ty_1 = ::core::ffi::c_uint;
8extern "C" {
9 #[doc = " result might be undefined when input_num is zero"]
10 pub fn roaring_trailing_zeroes(input_num: ::core::ffi::c_ulonglong) -> ::core::ffi::c_int;
11}
12extern "C" {
13 #[doc = " result might be undefined when input_num is zero"]
14 pub fn roaring_leading_zeroes(input_num: ::core::ffi::c_ulonglong) -> ::core::ffi::c_int;
15}
16#[doc = " Roaring arrays are array-based key-value pairs having containers as values\n and 16-bit integer keys. A roaring bitmap might be implemented as such."]
17#[repr(C)]
18#[derive(Debug, Copy, Clone)]
19pub struct roaring_array_s {
20 pub size: i32,
21 pub allocation_size: i32,
22 pub containers: *mut *mut ::core::ffi::c_void,
23 pub keys: *mut u16,
24 pub typecodes: *mut u8,
25 pub flags: u8,
26}
27#[doc = " Roaring arrays are array-based key-value pairs having containers as values\n and 16-bit integer keys. A roaring bitmap might be implemented as such."]
28pub type roaring_array_t = roaring_array_s;
29pub type roaring_iterator = ::core::option::Option<
30 unsafe extern "C" fn(value: u32, param: *mut ::core::ffi::c_void) -> bool,
31>;
32pub type roaring_iterator64 = ::core::option::Option<
33 unsafe extern "C" fn(value: u64, param: *mut ::core::ffi::c_void) -> bool,
34>;
35#[doc = " (For advanced users.)\n The roaring_statistics_t can be used to collect detailed statistics about\n the composition of a roaring bitmap."]
36#[repr(C)]
37#[derive(Debug, Copy, Clone)]
38pub struct roaring_statistics_s {
39 pub n_containers: u32,
40 pub n_array_containers: u32,
41 pub n_run_containers: u32,
42 pub n_bitset_containers: u32,
43 pub n_values_array_containers: u32,
44 pub n_values_run_containers: u32,
45 pub n_values_bitset_containers: u32,
46 pub n_bytes_array_containers: u32,
47 pub n_bytes_run_containers: u32,
48 pub n_bytes_bitset_containers: u32,
49 pub max_value: u32,
50 pub min_value: u32,
51 pub sum_value: u64,
52 pub cardinality: u64,
53}
54#[doc = " (For advanced users.)\n The roaring_statistics_t can be used to collect detailed statistics about\n the composition of a roaring bitmap."]
55pub type roaring_statistics_t = roaring_statistics_s;
56#[doc = " (For advanced users.)\n The roaring64_statistics_t can be used to collect detailed statistics about\n the composition of a roaring64 bitmap."]
57#[repr(C)]
58#[derive(Debug, Copy, Clone)]
59pub struct roaring64_statistics_s {
60 pub n_containers: u64,
61 pub n_array_containers: u64,
62 pub n_run_containers: u64,
63 pub n_bitset_containers: u64,
64 pub n_values_array_containers: u64,
65 pub n_values_run_containers: u64,
66 pub n_values_bitset_containers: u64,
67 pub n_bytes_array_containers: u64,
68 pub n_bytes_run_containers: u64,
69 pub n_bytes_bitset_containers: u64,
70 pub max_value: u64,
71 pub min_value: u64,
72 pub cardinality: u64,
73}
74#[doc = " (For advanced users.)\n The roaring64_statistics_t can be used to collect detailed statistics about\n the composition of a roaring64 bitmap."]
75pub type roaring64_statistics_t = roaring64_statistics_s;
76#[doc = " Roaring-internal type used to iterate within a roaring container."]
77#[repr(C)]
78#[derive(Debug, Copy, Clone)]
79pub struct roaring_container_iterator_s {
80 pub index: i32,
81}
82#[doc = " Roaring-internal type used to iterate within a roaring container."]
83pub type roaring_container_iterator_t = roaring_container_iterator_s;
84#[repr(C)]
85#[derive(Debug, Copy, Clone)]
86pub struct bitset_s {
87 pub array: *mut u64,
88 pub arraysize: usize,
89 pub capacity: usize,
90}
91pub type bitset_t = bitset_s;
92extern "C" {
93 pub fn bitset_create() -> *mut bitset_t;
94}
95extern "C" {
96 pub fn bitset_create_with_capacity(size: usize) -> *mut bitset_t;
97}
98extern "C" {
99 pub fn bitset_free(bitset: *mut bitset_t);
100}
101extern "C" {
102 pub fn bitset_clear(bitset: *mut bitset_t);
103}
104extern "C" {
105 pub fn bitset_fill(bitset: *mut bitset_t);
106}
107extern "C" {
108 pub fn bitset_copy(bitset: *const bitset_t) -> *mut bitset_t;
109}
110extern "C" {
111 pub fn bitset_resize(bitset: *mut bitset_t, newarraysize: usize, padwithzeroes: bool) -> bool;
112}
113extern "C" {
114 pub fn bitset_size_in_bytes(bitset: *const bitset_t) -> usize;
115}
116extern "C" {
117 pub fn bitset_size_in_bits(bitset: *const bitset_t) -> usize;
118}
119extern "C" {
120 pub fn bitset_size_in_words(bitset: *const bitset_t) -> usize;
121}
122extern "C" {
123 pub fn bitset_grow(bitset: *mut bitset_t, newarraysize: usize) -> bool;
124}
125extern "C" {
126 pub fn bitset_trim(bitset: *mut bitset_t) -> bool;
127}
128extern "C" {
129 pub fn bitset_shift_left(bitset: *mut bitset_t, s: usize);
130}
131extern "C" {
132 pub fn bitset_shift_right(bitset: *mut bitset_t, s: usize);
133}
134extern "C" {
135 pub fn bitset_set(bitset: *mut bitset_t, i: usize);
136}
137extern "C" {
138 pub fn bitset_set_to_value(bitset: *mut bitset_t, i: usize, flag: bool);
139}
140extern "C" {
141 pub fn bitset_get(bitset: *const bitset_t, i: usize) -> bool;
142}
143extern "C" {
144 pub fn bitset_count(bitset: *const bitset_t) -> usize;
145}
146extern "C" {
147 pub fn bitset_empty(bitset: *const bitset_t) -> bool;
148}
149extern "C" {
150 pub fn bitset_minimum(bitset: *const bitset_t) -> usize;
151}
152extern "C" {
153 pub fn bitset_maximum(bitset: *const bitset_t) -> usize;
154}
155extern "C" {
156 pub fn bitset_inplace_union(b1: *mut bitset_t, b2: *const bitset_t) -> bool;
157}
158extern "C" {
159 pub fn bitset_union_count(b1: *const bitset_t, b2: *const bitset_t) -> usize;
160}
161extern "C" {
162 pub fn bitset_inplace_intersection(b1: *mut bitset_t, b2: *const bitset_t);
163}
164extern "C" {
165 pub fn bitset_intersection_count(b1: *const bitset_t, b2: *const bitset_t) -> usize;
166}
167extern "C" {
168 pub fn bitsets_disjoint(b1: *const bitset_t, b2: *const bitset_t) -> bool;
169}
170extern "C" {
171 pub fn bitsets_intersect(b1: *const bitset_t, b2: *const bitset_t) -> bool;
172}
173extern "C" {
174 pub fn bitset_contains_all(b1: *const bitset_t, b2: *const bitset_t) -> bool;
175}
176extern "C" {
177 pub fn bitset_inplace_difference(b1: *mut bitset_t, b2: *const bitset_t);
178}
179extern "C" {
180 pub fn bitset_difference_count(b1: *const bitset_t, b2: *const bitset_t) -> usize;
181}
182extern "C" {
183 pub fn bitset_inplace_symmetric_difference(b1: *mut bitset_t, b2: *const bitset_t) -> bool;
184}
185extern "C" {
186 pub fn bitset_symmetric_difference_count(b1: *const bitset_t, b2: *const bitset_t) -> usize;
187}
188extern "C" {
189 pub fn bitset_next_set_bit(bitset: *const bitset_t, i: *mut usize) -> bool;
190}
191extern "C" {
192 pub fn bitset_next_set_bits(
193 bitset: *const bitset_t,
194 buffer: *mut usize,
195 capacity: usize,
196 startfrom: *mut usize,
197 ) -> usize;
198}
199pub type bitset_iterator = ::core::option::Option<
200 unsafe extern "C" fn(value: usize, param: *mut ::core::ffi::c_void) -> bool,
201>;
202extern "C" {
203 pub fn bitset_for_each(
204 b: *const bitset_t,
205 iterator: bitset_iterator,
206 ptr: *mut ::core::ffi::c_void,
207 ) -> bool;
208}
209extern "C" {
210 pub fn bitset_print(b: *const bitset_t);
211}
212#[repr(C)]
213#[derive(Debug, Copy, Clone)]
214pub struct roaring_bitmap_s {
215 pub high_low_container: roaring_array_t,
216}
217pub type roaring_bitmap_t = roaring_bitmap_s;
218extern "C" {
219 #[doc = " Dynamically allocates a new bitmap (initially empty).\n Returns NULL if the allocation fails.\n Capacity is a performance hint for how many \"containers\" the data will need.\n Client is responsible for calling `roaring_bitmap_free()`."]
220 pub fn roaring_bitmap_create_with_capacity(cap: u32) -> *mut roaring_bitmap_t;
221}
222extern "C" {
223 #[doc = " Dynamically allocates a new bitmap (initially empty).\n Returns NULL if the allocation fails.\n Client is responsible for calling `roaring_bitmap_free()`."]
224 pub fn roaring_bitmap_create() -> *mut roaring_bitmap_t;
225}
226extern "C" {
227 #[doc = " Initialize a roaring bitmap structure in memory controlled by client.\n Capacity is a performance hint for how many \"containers\" the data will need.\n Can return false if auxiliary allocations fail when capacity greater than 0."]
228 pub fn roaring_bitmap_init_with_capacity(r: *mut roaring_bitmap_t, cap: u32) -> bool;
229}
230extern "C" {
231 #[doc = " Initialize a roaring bitmap structure in memory controlled by client.\n The bitmap will be in a \"clear\" state, with no auxiliary allocations.\n Since this performs no allocations, the function will not fail."]
232 pub fn roaring_bitmap_init_cleared(r: *mut roaring_bitmap_t);
233}
234extern "C" {
235 #[doc = " Add all the values between min (included) and max (excluded) that are at a\n distance k*step from min.\n The returned pointer may be NULL in case of errors."]
236 pub fn roaring_bitmap_from_range(min: u64, max: u64, step: u32) -> *mut roaring_bitmap_t;
237}
238extern "C" {
239 #[doc = " Creates a new bitmap from a pointer of uint32_t integers\n The returned pointer may be NULL in case of errors."]
240 pub fn roaring_bitmap_of_ptr(n_args: usize, vals: *const u32) -> *mut roaring_bitmap_t;
241}
242extern "C" {
243 #[doc = " Check if the bitmap contains any shared containers."]
244 pub fn roaring_contains_shared(r: *const roaring_bitmap_t) -> bool;
245}
246extern "C" {
247 #[doc = " Unshare all shared containers.\n Returns true if any unsharing was performed, false if there were no shared\n containers."]
248 pub fn roaring_unshare_all(r: *mut roaring_bitmap_t) -> bool;
249}
250extern "C" {
251 pub fn roaring_bitmap_get_copy_on_write(r: *const roaring_bitmap_t) -> bool;
252}
253extern "C" {
254 pub fn roaring_bitmap_set_copy_on_write(r: *mut roaring_bitmap_t, cow: bool);
255}
256extern "C" {
257 #[doc = " Return a copy of the bitmap with all values shifted by offset.\n The returned pointer may be NULL in case of errors. The caller is responsible\n for freeing the return bitmap."]
258 pub fn roaring_bitmap_add_offset(
259 bm: *const roaring_bitmap_t,
260 offset: i64,
261 ) -> *mut roaring_bitmap_t;
262}
263extern "C" {
264 #[doc = " Describe the inner structure of the bitmap."]
265 pub fn roaring_bitmap_printf_describe(r: *const roaring_bitmap_t);
266}
267extern "C" {
268 #[doc = " Creates a new bitmap from a list of uint32_t integers\n\n This function is deprecated, use `roaring_bitmap_from` instead, which\n doesn't require the number of elements to be passed in.\n\n @see roaring_bitmap_from"]
269 pub fn roaring_bitmap_of(n: usize, ...) -> *mut roaring_bitmap_t;
270}
271extern "C" {
272 #[doc = " Copies a bitmap (this does memory allocation).\n The caller is responsible for memory management.\n The returned pointer may be NULL in case of errors."]
273 pub fn roaring_bitmap_copy(r: *const roaring_bitmap_t) -> *mut roaring_bitmap_t;
274}
275extern "C" {
276 #[doc = " Copies a bitmap from src to dest. It is assumed that the pointer dest\n is to an already allocated bitmap. The content of the dest bitmap is\n freed/deleted.\n\n It might be preferable and simpler to call roaring_bitmap_copy except\n that roaring_bitmap_overwrite can save on memory allocations.\n\n Returns true if successful, or false if there was an error. On failure,\n the dest bitmap is left in a valid, empty state (even if it was not empty\n before)."]
277 pub fn roaring_bitmap_overwrite(
278 dest: *mut roaring_bitmap_t,
279 src: *const roaring_bitmap_t,
280 ) -> bool;
281}
282extern "C" {
283 #[doc = " Print the content of the bitmap."]
284 pub fn roaring_bitmap_printf(r: *const roaring_bitmap_t);
285}
286extern "C" {
287 #[doc = " Computes the intersection between two bitmaps and returns new bitmap. The\n caller is responsible for memory management.\n\n Performance hint: if you are computing the intersection between several\n bitmaps, two-by-two, it is best to start with the smallest bitmap.\n You may also rely on roaring_bitmap_and_inplace to avoid creating\n many temporary bitmaps.\n The returned pointer may be NULL in case of errors."]
288 pub fn roaring_bitmap_and(
289 r1: *const roaring_bitmap_t,
290 r2: *const roaring_bitmap_t,
291 ) -> *mut roaring_bitmap_t;
292}
293extern "C" {
294 #[doc = " Computes the size of the intersection between two bitmaps."]
295 pub fn roaring_bitmap_and_cardinality(
296 r1: *const roaring_bitmap_t,
297 r2: *const roaring_bitmap_t,
298 ) -> u64;
299}
300extern "C" {
301 #[doc = " Check whether two bitmaps intersect."]
302 pub fn roaring_bitmap_intersect(
303 r1: *const roaring_bitmap_t,
304 r2: *const roaring_bitmap_t,
305 ) -> bool;
306}
307extern "C" {
308 #[doc = " Check whether a bitmap and an open range intersect."]
309 pub fn roaring_bitmap_intersect_with_range(bm: *const roaring_bitmap_t, x: u64, y: u64)
310 -> bool;
311}
312extern "C" {
313 #[doc = " Computes the Jaccard index between two bitmaps. (Also known as the Tanimoto\n distance, or the Jaccard similarity coefficient)\n\n The Jaccard index is undefined if both bitmaps are empty."]
314 pub fn roaring_bitmap_jaccard_index(
315 r1: *const roaring_bitmap_t,
316 r2: *const roaring_bitmap_t,
317 ) -> f64;
318}
319extern "C" {
320 #[doc = " Computes the size of the union between two bitmaps."]
321 pub fn roaring_bitmap_or_cardinality(
322 r1: *const roaring_bitmap_t,
323 r2: *const roaring_bitmap_t,
324 ) -> u64;
325}
326extern "C" {
327 #[doc = " Computes the size of the difference (andnot) between two bitmaps."]
328 pub fn roaring_bitmap_andnot_cardinality(
329 r1: *const roaring_bitmap_t,
330 r2: *const roaring_bitmap_t,
331 ) -> u64;
332}
333extern "C" {
334 #[doc = " Computes the size of the symmetric difference (xor) between two bitmaps."]
335 pub fn roaring_bitmap_xor_cardinality(
336 r1: *const roaring_bitmap_t,
337 r2: *const roaring_bitmap_t,
338 ) -> u64;
339}
340extern "C" {
341 #[doc = " Inplace version of `roaring_bitmap_and()`, modifies r1\n r1 == r2 is allowed.\n\n Performance hint: if you are computing the intersection between several\n bitmaps, two-by-two, it is best to start with the smallest bitmap."]
342 pub fn roaring_bitmap_and_inplace(r1: *mut roaring_bitmap_t, r2: *const roaring_bitmap_t);
343}
344extern "C" {
345 #[doc = " Computes the union between two bitmaps and returns new bitmap. The caller is\n responsible for memory management.\n The returned pointer may be NULL in case of errors."]
346 pub fn roaring_bitmap_or(
347 r1: *const roaring_bitmap_t,
348 r2: *const roaring_bitmap_t,
349 ) -> *mut roaring_bitmap_t;
350}
351extern "C" {
352 #[doc = " Inplace version of `roaring_bitmap_or(), modifies r1.\n TODO: decide whether r1 == r2 ok"]
353 pub fn roaring_bitmap_or_inplace(r1: *mut roaring_bitmap_t, r2: *const roaring_bitmap_t);
354}
355extern "C" {
356 #[doc = " Compute the union of 'number' bitmaps.\n Caller is responsible for freeing the result.\n See also `roaring_bitmap_or_many_heap()`\n The returned pointer may be NULL in case of errors."]
357 pub fn roaring_bitmap_or_many(
358 number: usize,
359 rs: *mut *const roaring_bitmap_t,
360 ) -> *mut roaring_bitmap_t;
361}
362extern "C" {
363 #[doc = " Compute the union of 'number' bitmaps using a heap. This can sometimes be\n faster than `roaring_bitmap_or_many() which uses a naive algorithm.\n Caller is responsible for freeing the result."]
364 pub fn roaring_bitmap_or_many_heap(
365 number: u32,
366 rs: *mut *const roaring_bitmap_t,
367 ) -> *mut roaring_bitmap_t;
368}
369extern "C" {
370 #[doc = " Computes the symmetric difference (xor) between two bitmaps\n and returns new bitmap. The caller is responsible for memory management.\n The returned pointer may be NULL in case of errors."]
371 pub fn roaring_bitmap_xor(
372 r1: *const roaring_bitmap_t,
373 r2: *const roaring_bitmap_t,
374 ) -> *mut roaring_bitmap_t;
375}
376extern "C" {
377 #[doc = " Inplace version of roaring_bitmap_xor, modifies r1, r1 != r2."]
378 pub fn roaring_bitmap_xor_inplace(r1: *mut roaring_bitmap_t, r2: *const roaring_bitmap_t);
379}
380extern "C" {
381 #[doc = " Compute the xor of 'number' bitmaps.\n Caller is responsible for freeing the result.\n The returned pointer may be NULL in case of errors."]
382 pub fn roaring_bitmap_xor_many(
383 number: usize,
384 rs: *mut *const roaring_bitmap_t,
385 ) -> *mut roaring_bitmap_t;
386}
387extern "C" {
388 #[doc = " Computes the difference (andnot) between two bitmaps and returns new bitmap.\n Caller is responsible for freeing the result.\n The returned pointer may be NULL in case of errors."]
389 pub fn roaring_bitmap_andnot(
390 r1: *const roaring_bitmap_t,
391 r2: *const roaring_bitmap_t,
392 ) -> *mut roaring_bitmap_t;
393}
394extern "C" {
395 #[doc = " Inplace version of roaring_bitmap_andnot, modifies r1, r1 != r2."]
396 pub fn roaring_bitmap_andnot_inplace(r1: *mut roaring_bitmap_t, r2: *const roaring_bitmap_t);
397}
398extern "C" {
399 #[doc = " Frees the memory."]
400 pub fn roaring_bitmap_free(r: *const roaring_bitmap_t);
401}
402#[doc = " A bit of context usable with `roaring_bitmap_*_bulk()` functions\n\n Should be initialized with `{0}` (or `memset()` to all zeros).\n Callers should treat it as an opaque type.\n\n A context may only be used with a single bitmap\n (unless re-initialized to zero), and any modification to a bitmap\n (other than modifications performed with `_bulk()` functions with the context\n passed) will invalidate any contexts associated with that bitmap."]
403#[repr(C)]
404#[derive(Debug, Copy, Clone)]
405pub struct roaring_bulk_context_s {
406 pub container: *mut ::core::ffi::c_void,
407 pub idx: ::core::ffi::c_int,
408 pub key: u16,
409 pub typecode: u8,
410}
411#[doc = " A bit of context usable with `roaring_bitmap_*_bulk()` functions\n\n Should be initialized with `{0}` (or `memset()` to all zeros).\n Callers should treat it as an opaque type.\n\n A context may only be used with a single bitmap\n (unless re-initialized to zero), and any modification to a bitmap\n (other than modifications performed with `_bulk()` functions with the context\n passed) will invalidate any contexts associated with that bitmap."]
412pub type roaring_bulk_context_t = roaring_bulk_context_s;
413extern "C" {
414 #[doc = " Add an item, using context from a previous insert for speed optimization.\n\n `context` will be used to store information between calls to make bulk\n operations faster. `*context` should be zero-initialized before the first\n call to this function.\n\n Modifying the bitmap in any way (other than `-bulk` suffixed functions)\n will invalidate the stored context, calling this function with a non-zero\n context after doing any modification invokes undefined behavior.\n\n In order to exploit this optimization, the caller should call this function\n with values with the same \"key\" (high 16 bits of the value) consecutively."]
415 pub fn roaring_bitmap_add_bulk(
416 r: *mut roaring_bitmap_t,
417 context: *mut roaring_bulk_context_t,
418 val: u32,
419 );
420}
421extern "C" {
422 #[doc = " Add value n_args from pointer vals, faster than repeatedly calling\n `roaring_bitmap_add()`\n\n In order to exploit this optimization, the caller should attempt to keep\n values with the same \"key\" (high 16 bits of the value) as consecutive\n elements in `vals`"]
423 pub fn roaring_bitmap_add_many(r: *mut roaring_bitmap_t, n_args: usize, vals: *const u32);
424}
425extern "C" {
426 #[doc = " Add value x"]
427 pub fn roaring_bitmap_add(r: *mut roaring_bitmap_t, x: u32);
428}
429extern "C" {
430 #[doc = " Add value x\n Returns true if a new value was added, false if the value already existed."]
431 pub fn roaring_bitmap_add_checked(r: *mut roaring_bitmap_t, x: u32) -> bool;
432}
433extern "C" {
434 #[doc = " Add all values in range [min, max]"]
435 pub fn roaring_bitmap_add_range_closed(r: *mut roaring_bitmap_t, min: u32, max: u32);
436}
437extern "C" {
438 #[doc = " Add all values in range [min, max)"]
439 pub fn roaring_bitmap_add_range(r: *mut roaring_bitmap_t, min: u64, max: u64);
440}
441extern "C" {
442 #[doc = " Remove value x"]
443 pub fn roaring_bitmap_remove(r: *mut roaring_bitmap_t, x: u32);
444}
445extern "C" {
446 #[doc = " Remove all values in range [min, max]"]
447 pub fn roaring_bitmap_remove_range_closed(r: *mut roaring_bitmap_t, min: u32, max: u32);
448}
449extern "C" {
450 #[doc = " Remove all values in range [min, max)"]
451 pub fn roaring_bitmap_remove_range(r: *mut roaring_bitmap_t, min: u64, max: u64);
452}
453extern "C" {
454 #[doc = " Remove multiple values"]
455 pub fn roaring_bitmap_remove_many(r: *mut roaring_bitmap_t, n_args: usize, vals: *const u32);
456}
457extern "C" {
458 #[doc = " Remove value x\n Returns true if a new value was removed, false if the value was not existing."]
459 pub fn roaring_bitmap_remove_checked(r: *mut roaring_bitmap_t, x: u32) -> bool;
460}
461extern "C" {
462 #[doc = " Check if value is present"]
463 pub fn roaring_bitmap_contains(r: *const roaring_bitmap_t, val: u32) -> bool;
464}
465extern "C" {
466 #[doc = " Check whether a range of values from range_start (included)\n to range_end (excluded) is present"]
467 pub fn roaring_bitmap_contains_range(
468 r: *const roaring_bitmap_t,
469 range_start: u64,
470 range_end: u64,
471 ) -> bool;
472}
473extern "C" {
474 #[doc = " Check whether a range of values from range_start (included)\n to range_end (included) is present"]
475 pub fn roaring_bitmap_contains_range_closed(
476 r: *const roaring_bitmap_t,
477 range_start: u32,
478 range_end: u32,
479 ) -> bool;
480}
481extern "C" {
482 #[doc = " Check if an items is present, using context from a previous insert or search\n for speed optimization.\n\n `context` will be used to store information between calls to make bulk\n operations faster. `*context` should be zero-initialized before the first\n call to this function.\n\n Modifying the bitmap in any way (other than `-bulk` suffixed functions)\n will invalidate the stored context, calling this function with a non-zero\n context after doing any modification invokes undefined behavior.\n\n In order to exploit this optimization, the caller should call this function\n with values with the same \"key\" (high 16 bits of the value) consecutively."]
483 pub fn roaring_bitmap_contains_bulk(
484 r: *const roaring_bitmap_t,
485 context: *mut roaring_bulk_context_t,
486 val: u32,
487 ) -> bool;
488}
489extern "C" {
490 #[doc = " Get the cardinality of the bitmap (number of elements)."]
491 pub fn roaring_bitmap_get_cardinality(r: *const roaring_bitmap_t) -> u64;
492}
493extern "C" {
494 #[doc = " Returns the number of elements in the range [range_start, range_end)."]
495 pub fn roaring_bitmap_range_cardinality(
496 r: *const roaring_bitmap_t,
497 range_start: u64,
498 range_end: u64,
499 ) -> u64;
500}
501extern "C" {
502 #[doc = " Returns the number of elements in the range [range_start, range_end]."]
503 pub fn roaring_bitmap_range_cardinality_closed(
504 r: *const roaring_bitmap_t,
505 range_start: u32,
506 range_end: u32,
507 ) -> u64;
508}
509extern "C" {
510 #[doc = " Returns true if the bitmap is empty (cardinality is zero)."]
511 pub fn roaring_bitmap_is_empty(r: *const roaring_bitmap_t) -> bool;
512}
513extern "C" {
514 #[doc = " Empties the bitmap. It will have no auxiliary allocations (so if the bitmap\n was initialized in client memory via roaring_bitmap_init(), then a call to\n roaring_bitmap_clear() would be enough to \"free\" it)"]
515 pub fn roaring_bitmap_clear(r: *mut roaring_bitmap_t);
516}
517extern "C" {
518 #[doc = " Convert the bitmap to a sorted array, output in `ans`.\n\n Caller is responsible to ensure that there is enough memory allocated, e.g.\n\n ans = malloc(roaring_bitmap_get_cardinality(bitmap) * sizeof(uint32_t));"]
519 pub fn roaring_bitmap_to_uint32_array(r: *const roaring_bitmap_t, ans: *mut u32);
520}
521extern "C" {
522 #[doc = " Store the bitmap to a bitset. This can be useful for people\n who need the performance and simplicity of a standard bitset.\n We assume that the input bitset is originally empty (does not\n have any set bit).\n\n bitset_t * out = bitset_create();\n // if the bitset has content in it, call \"bitset_clear(out)\"\n bool success = roaring_bitmap_to_bitset(mybitmap, out);\n // on failure, success will be false.\n // You can then query the bitset:\n bool is_present = bitset_get(out, 10011 );\n // you must free the memory:\n bitset_free(out);\n"]
523 pub fn roaring_bitmap_to_bitset(r: *const roaring_bitmap_t, bitset: *mut bitset_t) -> bool;
524}
525extern "C" {
526 #[doc = " Convert the bitmap to a sorted array from `offset` by `limit`, output in\n `ans`.\n\n Caller is responsible to ensure that there is enough memory allocated, e.g.\n\n ans = malloc(roaring_bitmap_get_cardinality(limit) * sizeof(uint32_t));\n\n This function always returns `true`\n\n For more control, see `roaring_uint32_iterator_skip` and\n `roaring_uint32_iterator_read`, which can be used to e.g. tell how many\n values were actually read."]
527 pub fn roaring_bitmap_range_uint32_array(
528 r: *const roaring_bitmap_t,
529 offset: usize,
530 limit: usize,
531 ans: *mut u32,
532 ) -> bool;
533}
534extern "C" {
535 #[doc = " Remove run-length encoding even when it is more space efficient.\n Return whether a change was applied."]
536 pub fn roaring_bitmap_remove_run_compression(r: *mut roaring_bitmap_t) -> bool;
537}
538extern "C" {
539 #[doc = " Convert array and bitmap containers to run containers when it is more\n efficient; also convert from run containers when more space efficient.\n\n Returns true if the result has at least one run container.\n Additional savings might be possible by calling `shrinkToFit()`."]
540 pub fn roaring_bitmap_run_optimize(r: *mut roaring_bitmap_t) -> bool;
541}
542extern "C" {
543 #[doc = " If needed, reallocate memory to shrink the memory usage.\n Returns the number of bytes saved."]
544 pub fn roaring_bitmap_shrink_to_fit(r: *mut roaring_bitmap_t) -> usize;
545}
546extern "C" {
547 #[doc = " Write the bitmap to an output pointer, this output buffer should refer to\n at least `roaring_bitmap_size_in_bytes(r)` allocated bytes.\n\n See `roaring_bitmap_portable_serialize()` if you want a format that's\n compatible with Java and Go implementations. This format can sometimes be\n more space efficient than the portable form, e.g. when the data is sparse.\n\n Returns how many bytes written, should be `roaring_bitmap_size_in_bytes(r)`.\n\n This function is endian-sensitive. If you have a big-endian system (e.g., a\n mainframe IBM s390x), the data format is going to be big-endian and not\n compatible with little-endian systems.\n\n When serializing data to a file, we recommend that you also use\n checksums so that, at deserialization, you can be confident\n that you are recovering the correct data."]
548 pub fn roaring_bitmap_serialize(
549 r: *const roaring_bitmap_t,
550 buf: *mut ::core::ffi::c_char,
551 ) -> usize;
552}
553extern "C" {
554 #[doc = " Use with `roaring_bitmap_serialize()`.\n\n (See `roaring_bitmap_portable_deserialize()` if you want a format that's\n compatible with Java and Go implementations).\n\n This function is endian-sensitive. If you have a big-endian system (e.g., a\n mainframe IBM s390x), the data format is going to be big-endian and not\n compatible with little-endian systems.\n\n The returned pointer may be NULL in case of errors."]
555 pub fn roaring_bitmap_deserialize(buf: *const ::core::ffi::c_void) -> *mut roaring_bitmap_t;
556}
557extern "C" {
558 #[doc = " Use with `roaring_bitmap_serialize()`.\n\n (See `roaring_bitmap_portable_deserialize_safe()` if you want a format that's\n compatible with Java and Go implementations).\n\n This function is endian-sensitive. If you have a big-endian system (e.g., a\n mainframe IBM s390x), the data format is going to be big-endian and not\n compatible with little-endian systems.\n\n The difference with `roaring_bitmap_deserialize()` is that this function\n checks that the input buffer is a valid bitmap. If the buffer is too small,\n NULL is returned.\n\n The returned pointer may be NULL in case of errors."]
559 pub fn roaring_bitmap_deserialize_safe(
560 buf: *const ::core::ffi::c_void,
561 maxbytes: usize,
562 ) -> *mut roaring_bitmap_t;
563}
564extern "C" {
565 #[doc = " How many bytes are required to serialize this bitmap (NOT compatible\n with Java and Go versions)"]
566 pub fn roaring_bitmap_size_in_bytes(r: *const roaring_bitmap_t) -> usize;
567}
568extern "C" {
569 #[doc = " Read bitmap from a serialized buffer.\n In case of failure, NULL is returned.\n\n This function is unsafe in the sense that if there is no valid serialized\n bitmap at the pointer, then many bytes could be read, possibly causing a\n buffer overflow. See also roaring_bitmap_portable_deserialize_safe().\n\n This is meant to be compatible with the Java and Go versions:\n https://github.com/RoaringBitmap/RoaringFormatSpec\n\n This function is endian-sensitive. If you have a big-endian system (e.g., a\n mainframe IBM s390x), the data format is going to be big-endian and not\n compatible with little-endian systems.\n\n The returned pointer may be NULL in case of errors."]
570 pub fn roaring_bitmap_portable_deserialize(
571 buf: *const ::core::ffi::c_char,
572 ) -> *mut roaring_bitmap_t;
573}
574extern "C" {
575 #[doc = " Read bitmap from a serialized buffer safely (reading up to maxbytes).\n In case of failure, NULL is returned.\n\n This is meant to be compatible with the Java and Go versions:\n https://github.com/RoaringBitmap/RoaringFormatSpec\n\n The function itself is safe in the sense that it will not cause buffer\n overflows: it will not read beyond the scope of the provided buffer\n (buf,maxbytes).\n\n However, for correct operations, it is assumed that the bitmap\n read was once serialized from a valid bitmap (i.e., it follows the format\n specification). If you provided an incorrect input (garbage), then the bitmap\n read may not be in a valid state and following operations may not lead to\n sensible results. In particular, the serialized array containers need to be\n in sorted order, and the run containers should be in sorted non-overlapping\n order. This is is guaranteed to happen when serializing an existing bitmap,\n but not for random inputs.\n\n If the source is untrusted, you should call\n roaring_bitmap_internal_validate to check the validity of the\n bitmap prior to using it. Only after calling roaring_bitmap_internal_validate\n is the bitmap considered safe for use.\n\n We also recommend that you use checksums to check that serialized data\n corresponds to the serialized bitmap. The CRoaring library does not provide\n checksumming.\n\n This function is endian-sensitive. If you have a big-endian system (e.g., a\n mainframe IBM s390x), the data format is going to be big-endian and not\n compatible with little-endian systems.\n\n The returned pointer may be NULL in case of errors."]
576 pub fn roaring_bitmap_portable_deserialize_safe(
577 buf: *const ::core::ffi::c_char,
578 maxbytes: usize,
579 ) -> *mut roaring_bitmap_t;
580}
581extern "C" {
582 #[doc = " Read bitmap from a serialized buffer.\n In case of failure, NULL is returned.\n\n Bitmap returned by this function can be used in all readonly contexts.\n Bitmap must be freed as usual, by calling roaring_bitmap_free().\n Underlying buffer must not be freed or modified while it backs any bitmaps.\n\n The function is unsafe in the following ways:\n 1) It may execute unaligned memory accesses.\n 2) A buffer overflow may occur if buf does not point to a valid serialized\n bitmap.\n\n This is meant to be compatible with the Java and Go versions:\n https://github.com/RoaringBitmap/RoaringFormatSpec\n\n This function is endian-sensitive. If you have a big-endian system (e.g., a\n mainframe IBM s390x), the data format is going to be big-endian and not\n compatible with little-endian systems.\n\n The returned pointer may be NULL in case of errors."]
583 pub fn roaring_bitmap_portable_deserialize_frozen(
584 buf: *const ::core::ffi::c_char,
585 ) -> *mut roaring_bitmap_t;
586}
587extern "C" {
588 #[doc = " Check how many bytes would be read (up to maxbytes) at this pointer if there\n is a bitmap, returns zero if there is no valid bitmap.\n\n This is meant to be compatible with the Java and Go versions:\n https://github.com/RoaringBitmap/RoaringFormatSpec"]
589 pub fn roaring_bitmap_portable_deserialize_size(
590 buf: *const ::core::ffi::c_char,
591 maxbytes: usize,
592 ) -> usize;
593}
594extern "C" {
595 #[doc = " How many bytes are required to serialize this bitmap.\n\n This is meant to be compatible with the Java and Go versions:\n https://github.com/RoaringBitmap/RoaringFormatSpec"]
596 pub fn roaring_bitmap_portable_size_in_bytes(r: *const roaring_bitmap_t) -> usize;
597}
598extern "C" {
599 #[doc = " Write a bitmap to a char buffer. The output buffer should refer to at least\n `roaring_bitmap_portable_size_in_bytes(r)` bytes of allocated memory.\n\n Returns how many bytes were written which should match\n `roaring_bitmap_portable_size_in_bytes(r)`.\n\n This is meant to be compatible with the Java and Go versions:\n https://github.com/RoaringBitmap/RoaringFormatSpec\n\n This function is endian-sensitive. If you have a big-endian system (e.g., a\n mainframe IBM s390x), the data format is going to be big-endian and not\n compatible with little-endian systems.\n\n When serializing data to a file, we recommend that you also use\n checksums so that, at deserialization, you can be confident\n that you are recovering the correct data."]
600 pub fn roaring_bitmap_portable_serialize(
601 r: *const roaring_bitmap_t,
602 buf: *mut ::core::ffi::c_char,
603 ) -> usize;
604}
605extern "C" {
606 #[doc = " Returns number of bytes required to serialize bitmap using frozen format."]
607 pub fn roaring_bitmap_frozen_size_in_bytes(r: *const roaring_bitmap_t) -> usize;
608}
609extern "C" {
610 #[doc = " Serializes bitmap using frozen format.\n Buffer size must be at least roaring_bitmap_frozen_size_in_bytes().\n\n This function is endian-sensitive. If you have a big-endian system (e.g., a\n mainframe IBM s390x), the data format is going to be big-endian and not\n compatible with little-endian systems.\n\n When serializing data to a file, we recommend that you also use\n checksums so that, at deserialization, you can be confident\n that you are recovering the correct data."]
611 pub fn roaring_bitmap_frozen_serialize(
612 r: *const roaring_bitmap_t,
613 buf: *mut ::core::ffi::c_char,
614 );
615}
616extern "C" {
617 #[doc = " Creates constant bitmap that is a view of a given buffer.\n Buffer data should have been written by `roaring_bitmap_frozen_serialize()`\n Its beginning must also be aligned by 32 bytes.\n Length must be equal exactly to `roaring_bitmap_frozen_size_in_bytes()`.\n In case of failure, NULL is returned.\n\n Bitmap returned by this function can be used in all readonly contexts.\n Bitmap must be freed as usual, by calling roaring_bitmap_free().\n Underlying buffer must not be freed or modified while it backs any bitmaps.\n\n This function is endian-sensitive. If you have a big-endian system (e.g., a\n mainframe IBM s390x), the data format is going to be big-endian and not\n compatible with little-endian systems."]
618 pub fn roaring_bitmap_frozen_view(
619 buf: *const ::core::ffi::c_char,
620 length: usize,
621 ) -> *const roaring_bitmap_t;
622}
623extern "C" {
624 #[doc = " Iterate over the bitmap elements. The function iterator is called once for\n all the values with ptr (can be NULL) as the second parameter of each call.\n\n `roaring_iterator` is simply a pointer to a function that returns bool\n (true means that the iteration should continue while false means that it\n should stop), and takes (uint32_t,void*) as inputs.\n\n Returns true if the roaring_iterator returned true throughout (so that all\n data points were necessarily visited).\n\n Iteration is ordered: from the smallest to the largest elements."]
625 pub fn roaring_iterate(
626 r: *const roaring_bitmap_t,
627 iterator: roaring_iterator,
628 ptr: *mut ::core::ffi::c_void,
629 ) -> bool;
630}
631extern "C" {
632 pub fn roaring_iterate64(
633 r: *const roaring_bitmap_t,
634 iterator: roaring_iterator64,
635 high_bits: u64,
636 ptr: *mut ::core::ffi::c_void,
637 ) -> bool;
638}
639extern "C" {
640 #[doc = " Return true if the two bitmaps contain the same elements."]
641 pub fn roaring_bitmap_equals(r1: *const roaring_bitmap_t, r2: *const roaring_bitmap_t) -> bool;
642}
643extern "C" {
644 #[doc = " Return true if all the elements of r1 are also in r2."]
645 pub fn roaring_bitmap_is_subset(
646 r1: *const roaring_bitmap_t,
647 r2: *const roaring_bitmap_t,
648 ) -> bool;
649}
650extern "C" {
651 #[doc = " Return true if all the elements of r1 are also in r2, and r2 is strictly\n greater than r1."]
652 pub fn roaring_bitmap_is_strict_subset(
653 r1: *const roaring_bitmap_t,
654 r2: *const roaring_bitmap_t,
655 ) -> bool;
656}
657extern "C" {
658 #[doc = " (For expert users who seek high performance.)\n\n Computes the union between two bitmaps and returns new bitmap. The caller is\n responsible for memory management.\n\n The lazy version defers some computations such as the maintenance of the\n cardinality counts. Thus you must call `roaring_bitmap_repair_after_lazy()`\n after executing \"lazy\" computations.\n\n It is safe to repeatedly call roaring_bitmap_lazy_or_inplace on the result.\n\n `bitsetconversion` is a flag which determines whether container-container\n operations force a bitset conversion.\n\n The returned pointer may be NULL in case of errors."]
659 pub fn roaring_bitmap_lazy_or(
660 r1: *const roaring_bitmap_t,
661 r2: *const roaring_bitmap_t,
662 bitsetconversion: bool,
663 ) -> *mut roaring_bitmap_t;
664}
665extern "C" {
666 #[doc = " (For expert users who seek high performance.)\n\n Inplace version of roaring_bitmap_lazy_or, modifies r1.\n\n `bitsetconversion` is a flag which determines whether container-container\n operations force a bitset conversion."]
667 pub fn roaring_bitmap_lazy_or_inplace(
668 r1: *mut roaring_bitmap_t,
669 r2: *const roaring_bitmap_t,
670 bitsetconversion: bool,
671 );
672}
673extern "C" {
674 #[doc = " (For expert users who seek high performance.)\n\n Execute maintenance on a bitmap created from `roaring_bitmap_lazy_or()`\n or modified with `roaring_bitmap_lazy_or_inplace()`."]
675 pub fn roaring_bitmap_repair_after_lazy(r1: *mut roaring_bitmap_t);
676}
677extern "C" {
678 #[doc = " Computes the symmetric difference between two bitmaps and returns new bitmap.\n The caller is responsible for memory management.\n\n The lazy version defers some computations such as the maintenance of the\n cardinality counts. Thus you must call `roaring_bitmap_repair_after_lazy()`\n after executing \"lazy\" computations.\n\n It is safe to repeatedly call `roaring_bitmap_lazy_xor_inplace()` on\n the result.\n\n The returned pointer may be NULL in case of errors."]
679 pub fn roaring_bitmap_lazy_xor(
680 r1: *const roaring_bitmap_t,
681 r2: *const roaring_bitmap_t,
682 ) -> *mut roaring_bitmap_t;
683}
684extern "C" {
685 #[doc = " (For expert users who seek high performance.)\n\n Inplace version of roaring_bitmap_lazy_xor, modifies r1. r1 != r2"]
686 pub fn roaring_bitmap_lazy_xor_inplace(r1: *mut roaring_bitmap_t, r2: *const roaring_bitmap_t);
687}
688extern "C" {
689 #[doc = " Compute the negation of the bitmap in the interval [range_start, range_end).\n The number of negated values is range_end - range_start.\n Areas outside the range are passed through unchanged.\n The returned pointer may be NULL in case of errors."]
690 pub fn roaring_bitmap_flip(
691 r1: *const roaring_bitmap_t,
692 range_start: u64,
693 range_end: u64,
694 ) -> *mut roaring_bitmap_t;
695}
696extern "C" {
697 #[doc = " Compute the negation of the bitmap in the interval [range_start, range_end].\n The number of negated values is range_end - range_start + 1.\n Areas outside the range are passed through unchanged.\n The returned pointer may be NULL in case of errors."]
698 pub fn roaring_bitmap_flip_closed(
699 x1: *const roaring_bitmap_t,
700 range_start: u32,
701 range_end: u32,
702 ) -> *mut roaring_bitmap_t;
703}
704extern "C" {
705 #[doc = " compute (in place) the negation of the roaring bitmap within a specified\n interval: [range_start, range_end). The number of negated values is\n range_end - range_start.\n Areas outside the range are passed through unchanged."]
706 pub fn roaring_bitmap_flip_inplace(r1: *mut roaring_bitmap_t, range_start: u64, range_end: u64);
707}
708extern "C" {
709 #[doc = " compute (in place) the negation of the roaring bitmap within a specified\n interval: [range_start, range_end]. The number of negated values is\n range_end - range_start + 1.\n Areas outside the range are passed through unchanged."]
710 pub fn roaring_bitmap_flip_inplace_closed(
711 r1: *mut roaring_bitmap_t,
712 range_start: u32,
713 range_end: u32,
714 );
715}
716extern "C" {
717 #[doc = " Selects the element at index 'rank' where the smallest element is at index 0.\n If the size of the roaring bitmap is strictly greater than rank, then this\n function returns true and sets element to the element of given rank.\n Otherwise, it returns false."]
718 pub fn roaring_bitmap_select(r: *const roaring_bitmap_t, rank: u32, element: *mut u32) -> bool;
719}
720extern "C" {
721 #[doc = " roaring_bitmap_rank returns the number of integers that are smaller or equal\n to x. Thus if x is the first element, this function will return 1. If\n x is smaller than the smallest element, this function will return 0.\n\n The indexing convention differs between roaring_bitmap_select and\n roaring_bitmap_rank: roaring_bitmap_select refers to the smallest value\n as having index 0, whereas roaring_bitmap_rank returns 1 when ranking\n the smallest value."]
722 pub fn roaring_bitmap_rank(r: *const roaring_bitmap_t, x: u32) -> u64;
723}
724extern "C" {
725 #[doc = " roaring_bitmap_rank_many is an `Bulk` version of `roaring_bitmap_rank`\n it puts rank value of each element in `[begin .. end)` to `ans[]`\n\n the values in `[begin .. end)` must be sorted in Ascending order;\n Caller is responsible to ensure that there is enough memory allocated, e.g.\n\n ans = malloc((end-begin) * sizeof(uint64_t));"]
726 pub fn roaring_bitmap_rank_many(
727 r: *const roaring_bitmap_t,
728 begin: *const u32,
729 end: *const u32,
730 ans: *mut u64,
731 );
732}
733extern "C" {
734 #[doc = " Returns the index of x in the given roaring bitmap.\n If the roaring bitmap doesn't contain x , this function will return -1.\n The difference with rank function is that this function will return -1 when x\n is not the element of roaring bitmap, but the rank function will return a\n non-negative number."]
735 pub fn roaring_bitmap_get_index(r: *const roaring_bitmap_t, x: u32) -> i64;
736}
737extern "C" {
738 #[doc = " Returns the smallest value in the set, or UINT32_MAX if the set is empty."]
739 pub fn roaring_bitmap_minimum(r: *const roaring_bitmap_t) -> u32;
740}
741extern "C" {
742 #[doc = " Returns the greatest value in the set, or 0 if the set is empty."]
743 pub fn roaring_bitmap_maximum(r: *const roaring_bitmap_t) -> u32;
744}
745extern "C" {
746 #[doc = " (For advanced users.)\n\n Collect statistics about the bitmap, see roaring_types.h for\n a description of roaring_statistics_t"]
747 pub fn roaring_bitmap_statistics(r: *const roaring_bitmap_t, stat: *mut roaring_statistics_t);
748}
749extern "C" {
750 #[doc = " Perform internal consistency checks. Returns true if the bitmap is\n consistent. It may be useful to call this after deserializing bitmaps from\n untrusted sources. If roaring_bitmap_internal_validate returns true, then the\n bitmap should be consistent and can be trusted not to cause crashes or memory\n corruption.\n\n Note that some operations intentionally leave bitmaps in an inconsistent\n state temporarily, for example, `roaring_bitmap_lazy_*` functions, until\n `roaring_bitmap_repair_after_lazy` is called.\n\n If reason is non-null, it will be set to a string describing the first\n inconsistency found if any."]
751 pub fn roaring_bitmap_internal_validate(
752 r: *const roaring_bitmap_t,
753 reason: *mut *const ::core::ffi::c_char,
754 ) -> bool;
755}
756#[doc = " A struct used to keep iterator state. Users should only access\n `current_value` and `has_value`, the rest of the type should be treated as\n opaque."]
757#[repr(C)]
758#[derive(Debug, Copy, Clone)]
759pub struct roaring_uint32_iterator_s {
760 pub parent: *const roaring_bitmap_t,
761 pub container: *const ::core::ffi::c_void,
762 pub typecode: u8,
763 pub container_index: i32,
764 pub highbits: u32,
765 pub container_it: roaring_container_iterator_t,
766 pub current_value: u32,
767 pub has_value: bool,
768}
769#[doc = " A struct used to keep iterator state. Users should only access\n `current_value` and `has_value`, the rest of the type should be treated as\n opaque."]
770pub type roaring_uint32_iterator_t = roaring_uint32_iterator_s;
771extern "C" {
772 #[doc = " Initialize an iterator object that can be used to iterate through the values.\n If there is a value, then this iterator points to the first value and\n `it->has_value` is true. The value is in `it->current_value`."]
773 pub fn roaring_iterator_init(r: *const roaring_bitmap_t, newit: *mut roaring_uint32_iterator_t);
774}
775extern "C" {
776 #[doc = " Initialize an iterator object that can be used to iterate through the values.\n If there is a value, then this iterator points to the last value and\n `it->has_value` is true. The value is in `it->current_value`."]
777 pub fn roaring_iterator_init_last(
778 r: *const roaring_bitmap_t,
779 newit: *mut roaring_uint32_iterator_t,
780 );
781}
782extern "C" {
783 #[doc = " Create an iterator object that can be used to iterate through the values.\n Caller is responsible for calling `roaring_free_iterator()`.\n\n The iterator is initialized (this function calls `roaring_iterator_init()`)\n If there is a value, then this iterator points to the first value and\n `it->has_value` is true. The value is in `it->current_value`."]
784 pub fn roaring_iterator_create(r: *const roaring_bitmap_t) -> *mut roaring_uint32_iterator_t;
785}
786extern "C" {
787 #[doc = " Advance the iterator. If there is a new value, then `it->has_value` is true.\n The new value is in `it->current_value`. Values are traversed in increasing\n orders. For convenience, returns `it->has_value`.\n\n Once `it->has_value` is false, `roaring_uint32_iterator_advance` should not\n be called on the iterator again. Calling `roaring_uint32_iterator_previous`\n is allowed."]
788 pub fn roaring_uint32_iterator_advance(it: *mut roaring_uint32_iterator_t) -> bool;
789}
790extern "C" {
791 #[doc = " Decrement the iterator. If there's a new value, then `it->has_value` is true.\n The new value is in `it->current_value`. Values are traversed in decreasing\n order. For convenience, returns `it->has_value`.\n\n Once `it->has_value` is false, `roaring_uint32_iterator_previous` should not\n be called on the iterator again. Calling `roaring_uint32_iterator_advance` is\n allowed."]
792 pub fn roaring_uint32_iterator_previous(it: *mut roaring_uint32_iterator_t) -> bool;
793}
794extern "C" {
795 #[doc = " Move the iterator to the first value >= `val`. If there is a such a value,\n then `it->has_value` is true. The new value is in `it->current_value`.\n For convenience, returns `it->has_value`."]
796 pub fn roaring_uint32_iterator_move_equalorlarger(
797 it: *mut roaring_uint32_iterator_t,
798 val: u32,
799 ) -> bool;
800}
801extern "C" {
802 #[doc = " Creates a copy of an iterator.\n Caller must free it."]
803 pub fn roaring_uint32_iterator_copy(
804 it: *const roaring_uint32_iterator_t,
805 ) -> *mut roaring_uint32_iterator_t;
806}
807extern "C" {
808 #[doc = " Free memory following `roaring_iterator_create()`"]
809 pub fn roaring_uint32_iterator_free(it: *mut roaring_uint32_iterator_t);
810}
811extern "C" {
812 #[doc = " Reads next ${count} values from iterator into user-supplied ${buf}.\n Returns the number of read elements.\n This number can be smaller than ${count}, which means that iterator is\n drained.\n\n This function satisfies semantics of iteration and can be used together with\n other iterator functions.\n - first value is copied from ${it}->current_value\n - after function returns, iterator is positioned at the next element"]
813 pub fn roaring_uint32_iterator_read(
814 it: *mut roaring_uint32_iterator_t,
815 buf: *mut u32,
816 count: u32,
817 ) -> u32;
818}
819extern "C" {
820 #[doc = " Skip the next ${count} values from iterator.\n Returns the number of values actually skipped.\n The number can be smaller than ${count}, which means that iterator is\n drained.\n\n This function is equivalent to calling `roaring_uint32_iterator_advance()`\n ${count} times but is much more efficient."]
821 pub fn roaring_uint32_iterator_skip(it: *mut roaring_uint32_iterator_t, count: u32) -> u32;
822}
823extern "C" {
824 #[doc = " Skip the previous ${count} values from iterator (move backwards).\n Returns the number of values actually skipped backwards.\n The number can be smaller than ${count}, which means that iterator reached\n the beginning.\n\n This function is equivalent to calling `roaring_uint32_iterator_previous()`\n ${count} times but is much more efficient."]
825 pub fn roaring_uint32_iterator_skip_backward(
826 it: *mut roaring_uint32_iterator_t,
827 count: u32,
828 ) -> u32;
829}
830pub type roaring_malloc_p =
831 ::core::option::Option<unsafe extern "C" fn(arg1: usize) -> *mut ::core::ffi::c_void>;
832pub type roaring_realloc_p = ::core::option::Option<
833 unsafe extern "C" fn(arg1: *mut ::core::ffi::c_void, arg2: usize) -> *mut ::core::ffi::c_void,
834>;
835pub type roaring_calloc_p = ::core::option::Option<
836 unsafe extern "C" fn(arg1: usize, arg2: usize) -> *mut ::core::ffi::c_void,
837>;
838pub type roaring_free_p =
839 ::core::option::Option<unsafe extern "C" fn(arg1: *mut ::core::ffi::c_void)>;
840pub type roaring_aligned_malloc_p = ::core::option::Option<
841 unsafe extern "C" fn(arg1: usize, arg2: usize) -> *mut ::core::ffi::c_void,
842>;
843pub type roaring_aligned_free_p =
844 ::core::option::Option<unsafe extern "C" fn(arg1: *mut ::core::ffi::c_void)>;
845#[repr(C)]
846#[derive(Debug, Copy, Clone)]
847pub struct roaring_memory_s {
848 pub malloc: roaring_malloc_p,
849 pub realloc: roaring_realloc_p,
850 pub calloc: roaring_calloc_p,
851 pub free: roaring_free_p,
852 pub aligned_malloc: roaring_aligned_malloc_p,
853 pub aligned_free: roaring_aligned_free_p,
854}
855pub type roaring_memory_t = roaring_memory_s;
856extern "C" {
857 pub fn roaring_init_memory_hook(memory_hook: roaring_memory_t);
858}
859extern "C" {
860 pub fn roaring_malloc(arg1: usize) -> *mut ::core::ffi::c_void;
861}
862extern "C" {
863 pub fn roaring_realloc(arg1: *mut ::core::ffi::c_void, arg2: usize)
864 -> *mut ::core::ffi::c_void;
865}
866extern "C" {
867 pub fn roaring_calloc(arg1: usize, arg2: usize) -> *mut ::core::ffi::c_void;
868}
869extern "C" {
870 pub fn roaring_free(arg1: *mut ::core::ffi::c_void);
871}
872extern "C" {
873 pub fn roaring_aligned_malloc(arg1: usize, arg2: usize) -> *mut ::core::ffi::c_void;
874}
875extern "C" {
876 pub fn roaring_aligned_free(arg1: *mut ::core::ffi::c_void);
877}
878#[repr(C)]
879#[derive(Debug, Copy, Clone)]
880pub struct roaring64_bitmap_s {
881 _unused: [u8; 0],
882}
883pub type roaring64_bitmap_t = roaring64_bitmap_s;
884pub type roaring64_leaf_t = u64;
885#[repr(C)]
886#[derive(Debug, Copy, Clone)]
887pub struct roaring64_iterator_s {
888 _unused: [u8; 0],
889}
890pub type roaring64_iterator_t = roaring64_iterator_s;
891#[doc = " A bit of context usable with `roaring64_bitmap_*_bulk()` functions.\n\n Should be initialized with `{0}` (or `memset()` to all zeros).\n Callers should treat it as an opaque type.\n\n A context may only be used with a single bitmap (unless re-initialized to\n zero), and any modification to a bitmap (other than modifications performed\n with `_bulk()` functions with the context passed) will invalidate any\n contexts associated with that bitmap."]
892#[repr(C)]
893#[derive(Debug, Copy, Clone)]
894pub struct roaring64_bulk_context_s {
895 pub high_bytes: [u8; 6usize],
896 pub leaf: *mut roaring64_leaf_t,
897}
898#[doc = " A bit of context usable with `roaring64_bitmap_*_bulk()` functions.\n\n Should be initialized with `{0}` (or `memset()` to all zeros).\n Callers should treat it as an opaque type.\n\n A context may only be used with a single bitmap (unless re-initialized to\n zero), and any modification to a bitmap (other than modifications performed\n with `_bulk()` functions with the context passed) will invalidate any\n contexts associated with that bitmap."]
899pub type roaring64_bulk_context_t = roaring64_bulk_context_s;
900extern "C" {
901 #[doc = " Dynamically allocates a new bitmap (initially empty).\n Client is responsible for calling `roaring64_bitmap_free()`.\n The returned pointer may be NULL in case of errors."]
902 pub fn roaring64_bitmap_create() -> *mut roaring64_bitmap_t;
903}
904extern "C" {
905 pub fn roaring64_bitmap_free(r: *mut roaring64_bitmap_t);
906}
907extern "C" {
908 #[doc = " Returns a copy of a bitmap.\n The returned pointer may be NULL in case of errors."]
909 pub fn roaring64_bitmap_copy(r: *const roaring64_bitmap_t) -> *mut roaring64_bitmap_t;
910}
911extern "C" {
912 #[doc = " Creates a new bitmap of a pointer to N 64-bit integers."]
913 pub fn roaring64_bitmap_of_ptr(n_args: usize, vals: *const u64) -> *mut roaring64_bitmap_t;
914}
915extern "C" {
916 #[doc = " Create a new bitmap by moving containers from a 32 bit roaring bitmap.\n\n After calling this function, the original bitmap will be empty, and the\n returned bitmap will contain all the values from the original bitmap."]
917 pub fn roaring64_bitmap_move_from_roaring32(
918 r: *mut roaring_bitmap_t,
919 ) -> *mut roaring64_bitmap_t;
920}
921extern "C" {
922 #[doc = " Create a new bitmap containing all the values in [min, max) that are at a\n distance k*step from min.\n The returned pointer may be NULL in case of errors."]
923 pub fn roaring64_bitmap_from_range(min: u64, max: u64, step: u64) -> *mut roaring64_bitmap_t;
924}
925extern "C" {
926 #[doc = " Adds the provided value to the bitmap."]
927 pub fn roaring64_bitmap_add(r: *mut roaring64_bitmap_t, val: u64);
928}
929extern "C" {
930 #[doc = " Adds the provided value to the bitmap.\n Returns true if a new value was added, false if the value already existed."]
931 pub fn roaring64_bitmap_add_checked(r: *mut roaring64_bitmap_t, val: u64) -> bool;
932}
933extern "C" {
934 #[doc = " Add an item, using context from a previous insert for faster insertion.\n\n `context` will be used to store information between calls to make bulk\n operations faster. `*context` should be zero-initialized before the first\n call to this function.\n\n Modifying the bitmap in any way (other than `-bulk` suffixed functions)\n will invalidate the stored context, calling this function with a non-zero\n context after doing any modification invokes undefined behavior.\n\n In order to exploit this optimization, the caller should call this function\n with values with the same high 48 bits of the value consecutively."]
935 pub fn roaring64_bitmap_add_bulk(
936 r: *mut roaring64_bitmap_t,
937 context: *mut roaring64_bulk_context_t,
938 val: u64,
939 );
940}
941extern "C" {
942 #[doc = " Add `n_args` values from `vals`, faster than repeatedly calling\n `roaring64_bitmap_add()`\n\n In order to exploit this optimization, the caller should attempt to keep\n values with the same high 48 bits of the value as consecutive elements in\n `vals`."]
943 pub fn roaring64_bitmap_add_many(r: *mut roaring64_bitmap_t, n_args: usize, vals: *const u64);
944}
945extern "C" {
946 #[doc = " Add all values in range [min, max)."]
947 pub fn roaring64_bitmap_add_range(r: *mut roaring64_bitmap_t, min: u64, max: u64);
948}
949extern "C" {
950 #[doc = " Add all values in range [min, max]."]
951 pub fn roaring64_bitmap_add_range_closed(r: *mut roaring64_bitmap_t, min: u64, max: u64);
952}
953extern "C" {
954 #[doc = " Removes a value from the bitmap if present."]
955 pub fn roaring64_bitmap_remove(r: *mut roaring64_bitmap_t, val: u64);
956}
957extern "C" {
958 #[doc = " Removes a value from the bitmap if present, returns true if the value was\n removed and false if the value was not present."]
959 pub fn roaring64_bitmap_remove_checked(r: *mut roaring64_bitmap_t, val: u64) -> bool;
960}
961extern "C" {
962 #[doc = " Remove an item, using context from a previous insert for faster removal.\n\n `context` will be used to store information between calls to make bulk\n operations faster. `*context` should be zero-initialized before the first\n call to this function.\n\n Modifying the bitmap in any way (other than `-bulk` suffixed functions)\n will invalidate the stored context, calling this function with a non-zero\n context after doing any modification invokes undefined behavior.\n\n In order to exploit this optimization, the caller should call this function\n with values with the same high 48 bits of the value consecutively."]
963 pub fn roaring64_bitmap_remove_bulk(
964 r: *mut roaring64_bitmap_t,
965 context: *mut roaring64_bulk_context_t,
966 val: u64,
967 );
968}
969extern "C" {
970 #[doc = " Remove `n_args` values from `vals`, faster than repeatedly calling\n `roaring64_bitmap_remove()`\n\n In order to exploit this optimization, the caller should attempt to keep\n values with the same high 48 bits of the value as consecutive elements in\n `vals`."]
971 pub fn roaring64_bitmap_remove_many(
972 r: *mut roaring64_bitmap_t,
973 n_args: usize,
974 vals: *const u64,
975 );
976}
977extern "C" {
978 #[doc = " Remove all values in range [min, max)."]
979 pub fn roaring64_bitmap_remove_range(r: *mut roaring64_bitmap_t, min: u64, max: u64);
980}
981extern "C" {
982 #[doc = " Remove all values in range [min, max]."]
983 pub fn roaring64_bitmap_remove_range_closed(r: *mut roaring64_bitmap_t, min: u64, max: u64);
984}
985extern "C" {
986 #[doc = " Empties the bitmap."]
987 pub fn roaring64_bitmap_clear(r: *mut roaring64_bitmap_t);
988}
989extern "C" {
990 #[doc = " Returns true if the provided value is present."]
991 pub fn roaring64_bitmap_contains(r: *const roaring64_bitmap_t, val: u64) -> bool;
992}
993extern "C" {
994 #[doc = " Returns true if all values in the range [min, max) are present."]
995 pub fn roaring64_bitmap_contains_range(
996 r: *const roaring64_bitmap_t,
997 min: u64,
998 max: u64,
999 ) -> bool;
1000}
1001extern "C" {
1002 #[doc = " Check if an item is present using context from a previous insert or search\n for faster search.\n\n `context` will be used to store information between calls to make bulk\n operations faster. `*context` should be zero-initialized before the first\n call to this function.\n\n Modifying the bitmap in any way (other than `-bulk` suffixed functions)\n will invalidate the stored context, calling this function with a non-zero\n context after doing any modification invokes undefined behavior.\n\n In order to exploit this optimization, the caller should call this function\n with values with the same high 48 bits of the value consecutively."]
1003 pub fn roaring64_bitmap_contains_bulk(
1004 r: *const roaring64_bitmap_t,
1005 context: *mut roaring64_bulk_context_t,
1006 val: u64,
1007 ) -> bool;
1008}
1009extern "C" {
1010 #[doc = " Selects the element at index 'rank' where the smallest element is at index 0.\n If the size of the bitmap is strictly greater than rank, then this function\n returns true and sets element to the element of given rank. Otherwise, it\n returns false."]
1011 pub fn roaring64_bitmap_select(
1012 r: *const roaring64_bitmap_t,
1013 rank: u64,
1014 element: *mut u64,
1015 ) -> bool;
1016}
1017extern "C" {
1018 #[doc = " Returns the number of integers that are smaller or equal to x. Thus if x is\n the first element, this function will return 1. If x is smaller than the\n smallest element, this function will return 0.\n\n The indexing convention differs between roaring64_bitmap_select and\n roaring64_bitmap_rank: roaring_bitmap64_select refers to the smallest value\n as having index 0, whereas roaring64_bitmap_rank returns 1 when ranking\n the smallest value."]
1019 pub fn roaring64_bitmap_rank(r: *const roaring64_bitmap_t, val: u64) -> u64;
1020}
1021extern "C" {
1022 #[doc = " Returns true if the given value is in the bitmap, and sets `out_index` to the\n (0-based) index of the value in the bitmap. Returns false if the value is not\n in the bitmap."]
1023 pub fn roaring64_bitmap_get_index(
1024 r: *const roaring64_bitmap_t,
1025 val: u64,
1026 out_index: *mut u64,
1027 ) -> bool;
1028}
1029extern "C" {
1030 #[doc = " Returns the number of values in the bitmap."]
1031 pub fn roaring64_bitmap_get_cardinality(r: *const roaring64_bitmap_t) -> u64;
1032}
1033extern "C" {
1034 #[doc = " Returns the number of elements in the range [min, max)."]
1035 pub fn roaring64_bitmap_range_cardinality(
1036 r: *const roaring64_bitmap_t,
1037 min: u64,
1038 max: u64,
1039 ) -> u64;
1040}
1041extern "C" {
1042 #[doc = " Returns the number of elements in the range [min, max]"]
1043 pub fn roaring64_bitmap_range_closed_cardinality(
1044 r: *const roaring64_bitmap_t,
1045 min: u64,
1046 max: u64,
1047 ) -> u64;
1048}
1049extern "C" {
1050 #[doc = " Returns true if the bitmap is empty (cardinality is zero)."]
1051 pub fn roaring64_bitmap_is_empty(r: *const roaring64_bitmap_t) -> bool;
1052}
1053extern "C" {
1054 #[doc = " Returns the smallest value in the set, or UINT64_MAX if the set is empty."]
1055 pub fn roaring64_bitmap_minimum(r: *const roaring64_bitmap_t) -> u64;
1056}
1057extern "C" {
1058 #[doc = " Returns the largest value in the set, or 0 if empty."]
1059 pub fn roaring64_bitmap_maximum(r: *const roaring64_bitmap_t) -> u64;
1060}
1061extern "C" {
1062 #[doc = " Returns true if the result has at least one run container."]
1063 pub fn roaring64_bitmap_run_optimize(r: *mut roaring64_bitmap_t) -> bool;
1064}
1065extern "C" {
1066 #[doc = " Shrinks internal arrays to eliminate any unused capacity. Returns the number\n of bytes freed."]
1067 pub fn roaring64_bitmap_shrink_to_fit(r: *mut roaring64_bitmap_t) -> usize;
1068}
1069extern "C" {
1070 #[doc = " (For advanced users.)\n Collect statistics about the bitmap"]
1071 pub fn roaring64_bitmap_statistics(
1072 r: *const roaring64_bitmap_t,
1073 stat: *mut roaring64_statistics_t,
1074 );
1075}
1076extern "C" {
1077 #[doc = " Perform internal consistency checks.\n\n Returns true if the bitmap is consistent. It may be useful to call this\n after deserializing bitmaps from untrusted sources. If\n roaring64_bitmap_internal_validate returns true, then the bitmap is\n consistent and can be trusted not to cause crashes or memory corruption.\n\n If reason is non-null, it will be set to a string describing the first\n inconsistency found if any."]
1078 pub fn roaring64_bitmap_internal_validate(
1079 r: *const roaring64_bitmap_t,
1080 reason: *mut *const ::core::ffi::c_char,
1081 ) -> bool;
1082}
1083extern "C" {
1084 #[doc = " Return true if the two bitmaps contain the same elements."]
1085 pub fn roaring64_bitmap_equals(
1086 r1: *const roaring64_bitmap_t,
1087 r2: *const roaring64_bitmap_t,
1088 ) -> bool;
1089}
1090extern "C" {
1091 #[doc = " Return true if all the elements of r1 are also in r2."]
1092 pub fn roaring64_bitmap_is_subset(
1093 r1: *const roaring64_bitmap_t,
1094 r2: *const roaring64_bitmap_t,
1095 ) -> bool;
1096}
1097extern "C" {
1098 #[doc = " Return true if all the elements of r1 are also in r2, and r2 is strictly\n greater than r1."]
1099 pub fn roaring64_bitmap_is_strict_subset(
1100 r1: *const roaring64_bitmap_t,
1101 r2: *const roaring64_bitmap_t,
1102 ) -> bool;
1103}
1104extern "C" {
1105 #[doc = " Computes the intersection between two bitmaps and returns new bitmap. The\n caller is responsible for free-ing the result.\n\n Performance hint: if you are computing the intersection between several\n bitmaps, two-by-two, it is best to start with the smallest bitmaps. You may\n also rely on roaring64_bitmap_and_inplace to avoid creating many temporary\n bitmaps.\n\n The returned pointer may be NULL in case of errors."]
1106 pub fn roaring64_bitmap_and(
1107 r1: *const roaring64_bitmap_t,
1108 r2: *const roaring64_bitmap_t,
1109 ) -> *mut roaring64_bitmap_t;
1110}
1111extern "C" {
1112 #[doc = " Computes the size of the intersection between two bitmaps."]
1113 pub fn roaring64_bitmap_and_cardinality(
1114 r1: *const roaring64_bitmap_t,
1115 r2: *const roaring64_bitmap_t,
1116 ) -> u64;
1117}
1118extern "C" {
1119 #[doc = " In-place version of `roaring64_bitmap_and()`, modifies `r1`. `r1` and `r2`\n are allowed to be equal.\n\n Performance hint: if you are computing the intersection between several\n bitmaps, two-by-two, it is best to start with the smallest bitmaps."]
1120 pub fn roaring64_bitmap_and_inplace(r1: *mut roaring64_bitmap_t, r2: *const roaring64_bitmap_t);
1121}
1122extern "C" {
1123 #[doc = " Check whether two bitmaps intersect."]
1124 pub fn roaring64_bitmap_intersect(
1125 r1: *const roaring64_bitmap_t,
1126 r2: *const roaring64_bitmap_t,
1127 ) -> bool;
1128}
1129extern "C" {
1130 #[doc = " Check whether a bitmap intersects the range [min, max)."]
1131 pub fn roaring64_bitmap_intersect_with_range(
1132 r: *const roaring64_bitmap_t,
1133 min: u64,
1134 max: u64,
1135 ) -> bool;
1136}
1137extern "C" {
1138 #[doc = " Computes the Jaccard index between two bitmaps. (Also known as the Tanimoto\n distance, or the Jaccard similarity coefficient)\n\n The Jaccard index is undefined if both bitmaps are empty."]
1139 pub fn roaring64_bitmap_jaccard_index(
1140 r1: *const roaring64_bitmap_t,
1141 r2: *const roaring64_bitmap_t,
1142 ) -> f64;
1143}
1144extern "C" {
1145 #[doc = " Computes the union between two bitmaps and returns new bitmap. The caller is\n responsible for free-ing the result.\n The returned pointer may be NULL in case of errors."]
1146 pub fn roaring64_bitmap_or(
1147 r1: *const roaring64_bitmap_t,
1148 r2: *const roaring64_bitmap_t,
1149 ) -> *mut roaring64_bitmap_t;
1150}
1151extern "C" {
1152 #[doc = " Computes the size of the union between two bitmaps."]
1153 pub fn roaring64_bitmap_or_cardinality(
1154 r1: *const roaring64_bitmap_t,
1155 r2: *const roaring64_bitmap_t,
1156 ) -> u64;
1157}
1158extern "C" {
1159 #[doc = " In-place version of `roaring64_bitmap_or(), modifies `r1`."]
1160 pub fn roaring64_bitmap_or_inplace(r1: *mut roaring64_bitmap_t, r2: *const roaring64_bitmap_t);
1161}
1162extern "C" {
1163 #[doc = " Computes the symmetric difference (xor) between two bitmaps and returns a new\n bitmap. The caller is responsible for free-ing the result.\n The returned pointer may be NULL in case of errors."]
1164 pub fn roaring64_bitmap_xor(
1165 r1: *const roaring64_bitmap_t,
1166 r2: *const roaring64_bitmap_t,
1167 ) -> *mut roaring64_bitmap_t;
1168}
1169extern "C" {
1170 #[doc = " Computes the size of the symmetric difference (xor) between two bitmaps."]
1171 pub fn roaring64_bitmap_xor_cardinality(
1172 r1: *const roaring64_bitmap_t,
1173 r2: *const roaring64_bitmap_t,
1174 ) -> u64;
1175}
1176extern "C" {
1177 #[doc = " In-place version of `roaring64_bitmap_xor()`, modifies `r1`. `r1` and `r2`\n are not allowed to be equal (that would result in an empty bitmap)."]
1178 pub fn roaring64_bitmap_xor_inplace(r1: *mut roaring64_bitmap_t, r2: *const roaring64_bitmap_t);
1179}
1180extern "C" {
1181 #[doc = " Computes the difference (andnot) between two bitmaps and returns a new\n bitmap. The caller is responsible for free-ing the result.\n The returned pointer may be NULL in case of errors."]
1182 pub fn roaring64_bitmap_andnot(
1183 r1: *const roaring64_bitmap_t,
1184 r2: *const roaring64_bitmap_t,
1185 ) -> *mut roaring64_bitmap_t;
1186}
1187extern "C" {
1188 #[doc = " Computes the size of the difference (andnot) between two bitmaps."]
1189 pub fn roaring64_bitmap_andnot_cardinality(
1190 r1: *const roaring64_bitmap_t,
1191 r2: *const roaring64_bitmap_t,
1192 ) -> u64;
1193}
1194extern "C" {
1195 #[doc = " In-place version of `roaring64_bitmap_andnot()`, modifies `r1`. `r1` and `r2`\n are not allowed to be equal (that would result in an empty bitmap)."]
1196 pub fn roaring64_bitmap_andnot_inplace(
1197 r1: *mut roaring64_bitmap_t,
1198 r2: *const roaring64_bitmap_t,
1199 );
1200}
1201extern "C" {
1202 #[doc = " Compute the negation of the bitmap in the interval [min, max).\n The number of negated values is `max - min`. Areas outside the range are\n passed through unchanged.\n The returned pointer may be NULL in case of errors."]
1203 pub fn roaring64_bitmap_flip(
1204 r: *const roaring64_bitmap_t,
1205 min: u64,
1206 max: u64,
1207 ) -> *mut roaring64_bitmap_t;
1208}
1209extern "C" {
1210 #[doc = " Compute the negation of the bitmap in the interval [min, max].\n The number of negated values is `max - min + 1`. Areas outside the range are\n passed through unchanged.\n The returned pointer may be NULL in case of errors."]
1211 pub fn roaring64_bitmap_flip_closed(
1212 r: *const roaring64_bitmap_t,
1213 min: u64,
1214 max: u64,
1215 ) -> *mut roaring64_bitmap_t;
1216}
1217extern "C" {
1218 #[doc = " In-place version of `roaring64_bitmap_flip`. Compute the negation of the\n bitmap in the interval [min, max). The number of negated values is `max -\n min`. Areas outside the range are passed through unchanged."]
1219 pub fn roaring64_bitmap_flip_inplace(r: *mut roaring64_bitmap_t, min: u64, max: u64);
1220}
1221extern "C" {
1222 #[doc = " In-place version of `roaring64_bitmap_flip_closed`. Compute the negation of\n the bitmap in the interval [min, max]. The number of negated values is `max -\n min + 1`. Areas outside the range are passed through unchanged."]
1223 pub fn roaring64_bitmap_flip_closed_inplace(r: *mut roaring64_bitmap_t, min: u64, max: u64);
1224}
1225extern "C" {
1226 #[doc = " How many bytes are required to serialize this bitmap.\n\n This is meant to be compatible with other languages:\n https://github.com/RoaringBitmap/RoaringFormatSpec#extension-for-64-bit-implementations"]
1227 pub fn roaring64_bitmap_portable_size_in_bytes(r: *const roaring64_bitmap_t) -> usize;
1228}
1229extern "C" {
1230 #[doc = " Write a bitmap to a buffer. The output buffer should refer to at least\n `roaring64_bitmap_portable_size_in_bytes(r)` bytes of allocated memory.\n\n Returns how many bytes were written, which should match\n `roaring64_bitmap_portable_size_in_bytes(r)`.\n\n This is meant to be compatible with other languages:\n https://github.com/RoaringBitmap/RoaringFormatSpec#extension-for-64-bit-implementations\n\n This function is endian-sensitive. If you have a big-endian system (e.g., a\n mainframe IBM s390x), the data format is going to be big-endian and not\n compatible with little-endian systems.\n\n When serializing data to a file, we recommend that you also use\n checksums so that, at deserialization, you can be confident\n that you are recovering the correct data."]
1231 pub fn roaring64_bitmap_portable_serialize(
1232 r: *const roaring64_bitmap_t,
1233 buf: *mut ::core::ffi::c_char,
1234 ) -> usize;
1235}
1236extern "C" {
1237 #[doc = " Check how many bytes would be read (up to maxbytes) at this pointer if there\n is a valid bitmap, returns zero if there is no valid bitmap.\n\n This is meant to be compatible with other languages\n https://github.com/RoaringBitmap/RoaringFormatSpec#extension-for-64-bit-implementations"]
1238 pub fn roaring64_bitmap_portable_deserialize_size(
1239 buf: *const ::core::ffi::c_char,
1240 maxbytes: usize,
1241 ) -> usize;
1242}
1243extern "C" {
1244 #[doc = " Read a bitmap from a serialized buffer (reading up to maxbytes).\n In case of failure, NULL is returned.\n\n This is meant to be compatible with other languages\n https://github.com/RoaringBitmap/RoaringFormatSpec#extension-for-64-bit-implementations\n\n The function itself is safe in the sense that it will not cause buffer\n overflows: it will not read beyond the scope of the provided buffer\n (buf,maxbytes).\n\n However, for correct operations, it is assumed that the bitmap\n read was once serialized from a valid bitmap (i.e., it follows the format\n specification). If you provided an incorrect input (garbage), then the bitmap\n read may not be in a valid state and following operations may not lead to\n sensible results. In particular, the serialized array containers need to be\n in sorted order, and the run containers should be in sorted non-overlapping\n order. This is is guaranteed to happen when serializing an existing bitmap,\n but not for random inputs.\n\n If the source is untrusted, you should call\n roaring64_bitmap_internal_validate to check the validity of the\n bitmap prior to using it. Only after calling\n roaring64_bitmap_internal_validate is the bitmap considered safe for use.\n\n We also recommend that you use checksums to check that serialized data\n corresponds to the serialized bitmap. The CRoaring library does not provide\n checksumming.\n\n This function is endian-sensitive. If you have a big-endian system (e.g., a\n mainframe IBM s390x), the data format is going to be big-endian and not\n compatible with little-endian systems."]
1245 pub fn roaring64_bitmap_portable_deserialize_safe(
1246 buf: *const ::core::ffi::c_char,
1247 maxbytes: usize,
1248 ) -> *mut roaring64_bitmap_t;
1249}
1250extern "C" {
1251 #[doc = " Returns the number of bytes required to serialize this bitmap in a \"frozen\"\n format. This is not compatible with any other serialization formats.\n\n `roaring64_bitmap_shrink_to_fit()` must be called before this method."]
1252 pub fn roaring64_bitmap_frozen_size_in_bytes(r: *const roaring64_bitmap_t) -> usize;
1253}
1254extern "C" {
1255 #[doc = " Serializes the bitmap in a \"frozen\" format. The given buffer must be at least\n `roaring64_bitmap_frozen_size_in_bytes()` in size. Returns the number of\n bytes used for serialization.\n\n `roaring64_bitmap_shrink_to_fit()` must be called before this method.\n\n The frozen format is optimized for speed of (de)serialization, as well as\n allowing the user to create a bitmap based on a memory mapped file, which is\n possible because the format mimics the memory layout of the bitmap.\n\n Because the format mimics the memory layout of the bitmap, the format is not\n fixed across releases of Roaring Bitmaps, and may change in future releases.\n\n This function is endian-sensitive. If you have a big-endian system (e.g., a\n mainframe IBM s390x), the data format is going to be big-endian and not\n compatible with little-endian systems."]
1256 pub fn roaring64_bitmap_frozen_serialize(
1257 r: *const roaring64_bitmap_t,
1258 buf: *mut ::core::ffi::c_char,
1259 ) -> usize;
1260}
1261extern "C" {
1262 #[doc = " Creates a readonly bitmap that is a view of the given buffer. The buffer\n must be created with `roaring64_bitmap_frozen_serialize()`, and must be\n aligned by 64 bytes.\n\n Returns NULL if deserialization fails.\n\n The returned bitmap must only be used in a readonly manner. The bitmap must\n be freed using `roaring64_bitmap_free()` as normal. The backing buffer must\n only be freed after the bitmap.\n\n This function is endian-sensitive. If you have a big-endian system (e.g., a\n mainframe IBM s390x), the data format is going to be big-endian and not\n compatible with little-endian systems."]
1263 pub fn roaring64_bitmap_frozen_view(
1264 buf: *const ::core::ffi::c_char,
1265 maxbytes: usize,
1266 ) -> *mut roaring64_bitmap_t;
1267}
1268extern "C" {
1269 #[doc = " Iterate over the bitmap elements. The function `iterator` is called once for\n all the values with `ptr` (can be NULL) as the second parameter of each call.\n\n `roaring_iterator64` is simply a pointer to a function that returns a bool\n and takes `(uint64_t, void*)` as inputs. True means that the iteration should\n continue, while false means that it should stop.\n\n Returns true if the `roaring64_iterator` returned true throughout (so that\n all data points were necessarily visited).\n\n Iteration is ordered from the smallest to the largest elements."]
1270 pub fn roaring64_bitmap_iterate(
1271 r: *const roaring64_bitmap_t,
1272 iterator: roaring_iterator64,
1273 ptr: *mut ::core::ffi::c_void,
1274 ) -> bool;
1275}
1276extern "C" {
1277 #[doc = " Convert the bitmap to a sorted array `out`.\n\n Caller is responsible to ensure that there is enough memory allocated, e.g.\n ```\n out = malloc(roaring64_bitmap_get_cardinality(bitmap) * sizeof(uint64_t));\n ```"]
1278 pub fn roaring64_bitmap_to_uint64_array(r: *const roaring64_bitmap_t, out: *mut u64);
1279}
1280extern "C" {
1281 #[doc = " Create an iterator object that can be used to iterate through the values.\n Caller is responsible for calling `roaring64_iterator_free()`.\n\n The iterator is initialized. If there is a value, then this iterator points\n to the first value and `roaring64_iterator_has_value()` returns true. The\n value can be retrieved with `roaring64_iterator_value()`."]
1282 pub fn roaring64_iterator_create(r: *const roaring64_bitmap_t) -> *mut roaring64_iterator_t;
1283}
1284extern "C" {
1285 #[doc = " Create an iterator object that can be used to iterate through the values.\n Caller is responsible for calling `roaring64_iterator_free()`.\n\n The iterator is initialized. If there is a value, then this iterator points\n to the last value and `roaring64_iterator_has_value()` returns true. The\n value can be retrieved with `roaring64_iterator_value()`."]
1286 pub fn roaring64_iterator_create_last(
1287 r: *const roaring64_bitmap_t,
1288 ) -> *mut roaring64_iterator_t;
1289}
1290extern "C" {
1291 #[doc = " Re-initializes an existing iterator. Functionally the same as\n `roaring64_iterator_create` without a allocation."]
1292 pub fn roaring64_iterator_reinit(r: *const roaring64_bitmap_t, it: *mut roaring64_iterator_t);
1293}
1294extern "C" {
1295 #[doc = " Re-initializes an existing iterator. Functionally the same as\n `roaring64_iterator_create_last` without a allocation."]
1296 pub fn roaring64_iterator_reinit_last(
1297 r: *const roaring64_bitmap_t,
1298 it: *mut roaring64_iterator_t,
1299 );
1300}
1301extern "C" {
1302 #[doc = " Creates a copy of the iterator. Caller is responsible for calling\n `roaring64_iterator_free()` on the resulting iterator."]
1303 pub fn roaring64_iterator_copy(it: *const roaring64_iterator_t) -> *mut roaring64_iterator_t;
1304}
1305extern "C" {
1306 #[doc = " Free the iterator."]
1307 pub fn roaring64_iterator_free(it: *mut roaring64_iterator_t);
1308}
1309extern "C" {
1310 #[doc = " Returns true if the iterator currently points to a value. If so, calling\n `roaring64_iterator_value()` returns the value."]
1311 pub fn roaring64_iterator_has_value(it: *const roaring64_iterator_t) -> bool;
1312}
1313extern "C" {
1314 #[doc = " Returns the value the iterator currently points to. Should only be called if\n `roaring64_iterator_has_value()` returns true."]
1315 pub fn roaring64_iterator_value(it: *const roaring64_iterator_t) -> u64;
1316}
1317extern "C" {
1318 #[doc = " Advance the iterator. If there is a new value, then\n `roaring64_iterator_has_value()` returns true. Values are traversed in\n increasing order. For convenience, returns the result of\n `roaring64_iterator_has_value()`.\n\n Once this returns false, `roaring64_iterator_advance` should not be called on\n the iterator again. Calling `roaring64_iterator_previous` is allowed."]
1319 pub fn roaring64_iterator_advance(it: *mut roaring64_iterator_t) -> bool;
1320}
1321extern "C" {
1322 #[doc = " Decrement the iterator. If there is a new value, then\n `roaring64_iterator_has_value()` returns true. Values are traversed in\n decreasing order. For convenience, returns the result of\n `roaring64_iterator_has_value()`.\n\n Once this returns false, `roaring64_iterator_previous` should not be called\n on the iterator again. Calling `roaring64_iterator_advance` is allowed."]
1323 pub fn roaring64_iterator_previous(it: *mut roaring64_iterator_t) -> bool;
1324}
1325extern "C" {
1326 #[doc = " Move the iterator to the first value greater than or equal to `val`, if it\n exists at or after the current position of the iterator. If there is a new\n value, then `roaring64_iterator_has_value()` returns true. Values are\n traversed in increasing order. For convenience, returns the result of\n `roaring64_iterator_has_value()`."]
1327 pub fn roaring64_iterator_move_equalorlarger(it: *mut roaring64_iterator_t, val: u64) -> bool;
1328}
1329extern "C" {
1330 #[doc = " Reads up to `count` values from the iterator into the given `buf`. Returns\n the number of elements read. The number of elements read can be smaller than\n `count`, which means that there are no more elements in the bitmap.\n\n This function can be used together with other iterator functions."]
1331 pub fn roaring64_iterator_read(it: *mut roaring64_iterator_t, buf: *mut u64, count: u64)
1332 -> u64;
1333}