Debian Codegraph @

gtk/roaring/roaring.h

raw symbols SCIP
1 /*
2 * Amalgamated copy of CRoaring 4.3.5, modified for GTK to reduce compiler
3 * warnings.
4 *
5 * Copyright 2016-2022 The CRoaring authors
6 * Copyright 2025 Red Hat, Inc
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 *
20 * SPDX-License-Identifier: Apache-2.0
21 */
22
23 /* begin file include/roaring/roaring_version.h */
24 // clang-format off
25 // /include/roaring/roaring_version.h automatically generated by release.py, do not change by hand
26 #ifndef ROARING_INCLUDE_ROARING_VERSIONcxx . . $ `gtk/roaring/roaring.h:27:9`!
27 #define ROARING_INCLUDE_ROARING_VERSIONcxx . . $ `gtk/roaring/roaring.h:27:9`!
28 #define ROARING_VERSIONcxx . . $ `gtk/roaring/roaring.h:28:9`! "4.3.5"
29 enumcxx . . $ $anonymous_type_5bb7c58ff8048535_0# {
30 ROARING_VERSION_MAJORcxx . . $ ROARING_VERSION_MAJOR. = 4,
31 ROARING_VERSION_MINORcxx . . $ ROARING_VERSION_MINOR. = 3,
32 ROARING_VERSION_REVISIONcxx . . $ ROARING_VERSION_REVISION. = 5
33 };
34 #endif // ROARING_INCLUDE_ROARING_VERSION
35 // clang-format on/* end file include/roaring/roaring_version.h */
36 /* begin file include/roaring/portability.h */
37 /*
38 * portability.h
39 *
40 */
41
42 /**
43 * All macros should be prefixed with either CROARING or ROARING.
44 * The library uses both ROARING_...
45 * as well as CROAIRING_ as prefixes. The ROARING_ prefix is for
46 * macros that are provided by the build system or that are closely
47 * related to the format. The header macros may also use ROARING_.
48 * The CROARING_ prefix is for internal macros that a user is unlikely
49 * to ever interact with.
50 */
51
52 #ifndef CROARING_INCLUDE_PORTABILITY_H_cxx . . $ `gtk/roaring/roaring.h:53:9`!
53 #define CROARING_INCLUDE_PORTABILITY_H_cxx . . $ `gtk/roaring/roaring.h:53:9`!
54
55 // Users who need _GNU_SOURCE should define it?
56 // #ifndef _GNU_SOURCE
57 // #define _GNU_SOURCE 1
58 // #endif // _GNU_SOURCE
59 #ifndef __STDC_FORMAT_MACROS
60 #define __STDC_FORMAT_MACROScxx . . $ `gtk/roaring/roaring.h:60:9`! 1
61 #endif // __STDC_FORMAT_MACROS
62
63 #ifdef _MSC_VER
64 #define CROARING_VISUAL_STUDIO 1
65 /**
66 * We want to differentiate carefully between
67 * clang under visual studio and regular visual
68 * studio.
69 */
70 #ifdef __clang__
71 // clang under visual studio
72 #define CROARING_CLANG_VISUAL_STUDIO 1
73 #else
74 // just regular visual studio (best guess)
75 #define CROARING_REGULAR_VISUAL_STUDIO 1
76 #endif // __clang__
77 #endif // _MSC_VER
78 #ifndef CROARING_VISUAL_STUDIO
79 #define CROARING_VISUAL_STUDIOcxx . . $ `gtk/roaring/roaring.h:79:9`! 0
80 #endif
81 #ifndef CROARING_CLANG_VISUAL_STUDIO
82 #define CROARING_CLANG_VISUAL_STUDIOcxx . . $ `gtk/roaring/roaring.h:82:9`! 0
83 #endif
84 #ifndef CROARING_REGULAR_VISUAL_STUDIO
85 #define CROARING_REGULAR_VISUAL_STUDIOcxx . . $ `gtk/roaring/roaring.h:85:9`! 0
86 #endif
87
88 #include <stdbool.h>
89 #include <stdint.h>
90 #include <stdlib.h> // will provide posix_memalign with _POSIX_C_SOURCE as defined above
91 #ifdef __GLIBC__cxx . . $ `<external>/18206667465210621810/features.h:514:9`!
92 #include <malloc.h> // this should never be needed but there are some reports that it is needed.
93 #endif
94
95 #ifdef __cplusplus
96 extern "C" { // portability definitions are in global scope, not a namespace
97 #endif
98
99 #if defined(__SIZEOF_LONG_LONG__cxx . . $ `<built-in>:85:9`!) && __SIZEOF_LONG_LONG__cxx . . $ `<built-in>:85:9`! != 8
100 #error This code assumes 64-bit long longs (by use of the GCC intrinsics). Your system is not currently supported.
101 #endif
102
103 #if CROARING_REGULAR_VISUAL_STUDIOcxx . . $ `gtk/roaring/roaring.h:85:9`!
104 #ifndef __restrict__
105 #define __restrict__ __restrict
106 #endif // __restrict__
107 #endif // CROARING_REGULAR_VISUAL_STUDIO
108
109 #if defined(__x86_64__cxx . . $ `<built-in>:372:9`!) || defined(_M_X64)
110 // we have an x64 processor
111 #define CROARING_IS_X64cxx . . $ `gtk/roaring/roaring.h:111:9`! 1
112
113 #if defined(_MSC_VER) && (_MSC_VER < 1910)
114 // Old visual studio systems won't support AVX2 well.
115 #undef CROARING_IS_X64
116 #endif
117
118 #if defined(__clang_major__cxx . . $ `<built-in>:4:9`!) && (__clang_major__cxx . . $ `<built-in>:4:9`! <= 8) && !defined(__AVX2__)
119 // Older versions of clang have a bug affecting us
120 // https://stackoverflow.com/questions/57228537/how-does-one-use-pragma-clang-attribute-push-with-c-namespaces
121 #undef CROARING_IS_X64
122 #endif
123
124 #ifdef ROARING_DISABLE_X64
125 #undef CROARING_IS_X64
126 #endif
127 // we include the intrinsic header
128 #if !CROARING_REGULAR_VISUAL_STUDIOcxx . . $ `gtk/roaring/roaring.h:85:9`!
129 /* Non-Microsoft C/C++-compatible compiler */
130 #include <x86intrin.h> // on some recent GCC, this will declare posix_memalign
131
132 #if CROARING_CLANG_VISUAL_STUDIOcxx . . $ `gtk/roaring/roaring.h:82:9`!
133
134 /**
135 * You are not supposed, normally, to include these
136 * headers directly. Instead you should either include intrin.h
137 * or x86intrin.h. However, when compiling with clang
138 * under Windows (i.e., when _MSC_VER is set), these headers
139 * only get included *if* the corresponding features are detected
140 * from macros:
141 * e.g., if __AVX2__ is set... in turn, we normally set these
142 * macros by compiling against the corresponding architecture
143 * (e.g., arch:AVX2, -mavx2, etc.) which compiles the whole
144 * software with these advanced instructions. These headers would
145 * normally guard against such usage, but we carefully included
146 * <x86intrin.h> (or <intrin.h>) before, so the headers
147 * are fooled.
148 */
149 // To avoid reordering imports:
150 // clang-format off
151 #include <bmiintrin.h> // for _blsr_u64
152 #include <lzcntintrin.h> // for __lzcnt64
153 #include <immintrin.h> // for most things (AVX2, AVX512, _popcnt64)
154 #include <smmintrin.h>
155 #include <tmmintrin.h>
156 #include <avxintrin.h>
157 #include <avx2intrin.h>
158 #include <wmmintrin.h>
159 #if _MSC_VER >= 1920
160 // Important: we need the AVX-512 headers:
161 #include <avx512fintrin.h>
162 #include <avx512dqintrin.h>
163 #include <avx512cdintrin.h>
164 #include <avx512bwintrin.h>
165 #include <avx512vlintrin.h>
166 #include <avx512vbmiintrin.h>
167 #include <avx512vbmi2intrin.h>
168 #include <avx512vpopcntdqintrin.h>
169 // clang-format on
170 #endif // _MSC_VER >= 1920
171 // unfortunately, we may not get _blsr_u64, but, thankfully, clang
172 // has it as a macro.
173 #ifndef _blsr_u64
174 // we roll our own
175 #define _blsr_u64(n) ((n - 1) & n)
176 #endif // _blsr_u64
177 #endif // SIMDJSON_CLANG_VISUAL_STUDIO
178
179 #endif // CROARING_REGULAR_VISUAL_STUDIO
180 #endif // defined(__x86_64__) || defined(_M_X64)
181
182 #if !defined(CROARING_USENEON) && !defined(DISABLENEON) && defined(__ARM_NEON)
183 #define CROARING_USENEON
184 #endif
185 #if defined(CROARING_USENEON)
186 #include <arm_neon.h>
187 #endif
188
189 #if !CROARING_REGULAR_VISUAL_STUDIOcxx . . $ `gtk/roaring/roaring.h:85:9`!
190 /* Non-Microsoft C/C++-compatible compiler, assumes that it supports inline
191 * assembly */
192 #define CROARING_INLINE_ASMcxx . . $ `gtk/roaring/roaring.h:192:9`! 1
193 #endif // _MSC_VER
194
195 #if CROARING_REGULAR_VISUAL_STUDIOcxx . . $ `gtk/roaring/roaring.h:85:9`!
196 /* Microsoft C/C++-compatible compiler */
197 #include <intrin.h>
198
199 #ifndef __clang__ // if one compiles with MSVC *with* clang, then these
200 // intrinsics are defined!!!
201 #define CROARING_INTRINSICS 1
202 // sadly there is no way to check whether we are missing these intrinsics
203 // specifically.
204
205 /* wrappers for Visual Studio built-ins that look like gcc built-ins
206 * __builtin_ctzll */
207 /** result might be undefined when input_num is zero */
208 static inline int roaring_trailing_zeroes(unsigned long long input_num) {
209 unsigned long index;
210 #ifdef _WIN64 // highly recommended!!!
211 _BitScanForward64(&index, input_num);
212 #else // if we must support 32-bit Windows
213 if ((uint32_t)input_num != 0) {
214 _BitScanForward(&index, (uint32_t)input_num);
215 } else {
216 _BitScanForward(&index, (uint32_t)(input_num >> 32));
217 index += 32;
218 }
219 #endif // _WIN64
220 return index;
221 }
222
223 /* wrappers for Visual Studio built-ins that look like gcc built-ins
224 * __builtin_clzll */
225 /** result might be undefined when input_num is zero */
226 static inline int roaring_leading_zeroes(unsigned long long input_num) {
227 unsigned long index;
228 #ifdef _WIN64 // highly recommended!!!
229 _BitScanReverse64(&index, input_num);
230 #else // if we must support 32-bit Windows
231 if (input_num > 0xFFFFFFFF) {
232 _BitScanReverse(&index, (uint32_t)(input_num >> 32));
233 index += 32;
234 } else {
235 _BitScanReverse(&index, (uint32_t)(input_num));
236 }
237 #endif // _WIN64
238 return 63 - index;
239 }
240
241 /* Use #define so this is effective even under /Ob0 (no inline) */
242 #define roaring_unreachable __assume(0)
243 #endif // __clang__
244
245 #endif // CROARING_REGULAR_VISUAL_STUDIO
246
247 #ifndef CROARING_INTRINSICS
248 #define CROARING_INTRINSICScxx . . $ `gtk/roaring/roaring.h:248:9`! 1
249 #define roaring_unreachablecxx . . $ `gtk/roaring/roaring.h:249:9`! __builtin_unreachable()
250 /** result might be undefined when input_num is zero */
251 static inline int roaring_trailing_zeroescxx . . $ roaring_trailing_zeroes(642c2e9948c4ad2).(unsigned long long input_num) {
252 return __builtin_ctzllcxx . . $ __builtin_ctzll(642c2e9948c4ad2).(input_num);
253 }
254 /** result might be undefined when input_num is zero */
255 static inline int roaring_leading_zeroescxx . . $ roaring_leading_zeroes(642c2e9948c4ad2).(unsigned long long input_num) {
256 return __builtin_clzllcxx . . $ __builtin_clzll(642c2e9948c4ad2).(input_num);
257 }
258 #endif
259
260 #if CROARING_REGULAR_VISUAL_STUDIOcxx . . $ `gtk/roaring/roaring.h:85:9`!
261 #define ALIGNED(x) __declspec(align(x))
262 #elif defined(__GNUC__cxx . . $ `<built-in>:8:9`!) || defined(__clang__cxx . . $ `<built-in>:3:9`!)
263 #define ALIGNEDcxx . . $ `gtk/roaring/roaring.h:263:9`!(x) __attribute__((aligned(x)))
264 #else
265 #warning "Warning. Unrecognized compiler."
266 #define ALIGNED(x)
267 #endif
268
269 #if defined(__GNUC__cxx . . $ `<built-in>:8:9`!) || defined(__clang__cxx . . $ `<built-in>:3:9`!)
270 #define CROARING_WARN_UNUSEDcxx . . $ `gtk/roaring/roaring.h:270:9`! __attribute__((warn_unused_result))
271 #else
272 #define CROARING_WARN_UNUSED
273 #endif
274
275 #define IS_BIG_ENDIANcxx . . $ `gtk/roaring/roaring.h:275:9`! (*(uint16_t *)"\0\xff" < 0x100)
276
277 #ifdef CROARING_USENEON
278 // we can always compute the popcount fast.
279 #elif (defined(_M_ARM) || defined(_M_ARM64)) && \
280 ((defined(_WIN64) || defined(_WIN32)) && \
281 defined(CROARING_REGULAR_VISUAL_STUDIOcxx . . $ `gtk/roaring/roaring.h:85:9`!) && \
282 CROARING_REGULAR_VISUAL_STUDIOcxx . . $ `gtk/roaring/roaring.h:85:9`!)
283 // we will need this function:
284 static inline int roaring_hamming_backup(uint64_t x) {
285 uint64_t c1 = UINT64_C(0x5555555555555555);
286 uint64_t c2 = UINT64_C(0x3333333333333333);
287 uint64_t c4 = UINT64_C(0x0F0F0F0F0F0F0F0F);
288 x -= (x >> 1) & c1;
289 x = ((x >> 2) & c2) + (x & c2);
290 x = (x + (x >> 4)) & c4;
291 x *= UINT64_C(0x0101010101010101);
292 return x >> 56;
293 }
294 #endif
295
296 static inline int roaring_hammingcxx . . $ roaring_hamming(15f694ef3c96d230).(uint64_tcxx . . $ uint64_t# x) {
297 #if defined(_WIN64) && defined(CROARING_REGULAR_VISUAL_STUDIOcxx . . $ `gtk/roaring/roaring.h:85:9`!) && \
298 CROARING_REGULAR_VISUAL_STUDIOcxx . . $ `gtk/roaring/roaring.h:85:9`!
299 #ifdef CROARING_USENEON
300 return vaddv_u8(vcnt_u8(vcreate_u8(input_num)));
301 #elif defined(_M_ARM64)
302 return roaring_hamming_backup(x);
303 // (int) _CountOneBits64(x); is unavailable
304 #else // _M_ARM64
305 return (int)__popcnt64(x);
306 #endif // _M_ARM64
307 #elif defined(_WIN32) && defined(CROARING_REGULAR_VISUAL_STUDIOcxx . . $ `gtk/roaring/roaring.h:85:9`!) && \
308 CROARING_REGULAR_VISUAL_STUDIOcxx . . $ `gtk/roaring/roaring.h:85:9`!
309 #ifdef _M_ARM
310 return roaring_hamming_backup(x);
311 // _CountOneBits is unavailable
312 #else // _M_ARM
313 return (int)__popcnt((unsigned int)x) +
314 (int)__popcnt((unsigned int)(x >> 32));
315 #endif // _M_ARM
316 #else
317 return __builtin_popcountllcxx . . $ __builtin_popcountll(642c2e9948c4ad2).(x);
318 #endif
319 }
320
321 #ifndef UINT64_Ccxx . . $ `<external>/3415975807581488833/stdint.h:251:11`!
322 #define UINT64_C(c) (c##ULL)
323 #endif // UINT64_C
324
325 #ifndef UINT32_Ccxx . . $ `<external>/3415975807581488833/stdint.h:249:10`!
326 #define UINT32_C(c) (c##UL)
327 #endif // UINT32_C
328
329 #ifdef __cplusplus
330 } // extern "C" {
331 #endif // __cplusplus
332
333 // this is almost standard?
334 #undef STRINGIFY_IMPLEMENTATION_
335 #undef STRINGIFY
336 #define STRINGIFY_IMPLEMENTATION_cxx . . $ `gtk/roaring/roaring.h:336:9`!(a) #a
337 #define STRINGIFYcxx . . $ `gtk/roaring/roaring.h:337:9`!(a) STRINGIFY_IMPLEMENTATION_cxx . . $ `gtk/roaring/roaring.h:336:9`!(a)
338
339 // Our fast kernels require 64-bit systems.
340 //
341 // On 32-bit x86, we lack 64-bit popcnt, lzcnt, blsr instructions.
342 // Furthermore, the number of SIMD registers is reduced.
343 //
344 // On 32-bit ARM, we would have smaller registers.
345 //
346 // The library should still have the fallback kernel. It is
347 // slower, but it should run everywhere.
348
349 //
350 // Enable valid runtime implementations, and select
351 // CROARING_BUILTIN_IMPLEMENTATION
352 //
353
354 // We are going to use runtime dispatch.
355 #ifdef CROARING_IS_X64cxx . . $ `gtk/roaring/roaring.h:111:9`!
356 #ifdef __clang__cxx . . $ `<built-in>:3:9`!
357 // clang does not have GCC push pop
358 // warning: clang attribute push can't be used within a namespace in clang up
359 // til 8.0 so CROARING_TARGET_REGION and CROARING_UNTARGET_REGION must be
360 // *outside* of a namespace.
361 #define CROARING_TARGET_REGIONcxx . . $ `gtk/roaring/roaring.h:361:9`!(T) \
362 _Pragma(STRINGIFYcxx . . $ `gtk/roaring/roaring.h:337:9`!(clang attribute push(__attribute__((target(T))), \
363 apply_to = function)))
364 #define CROARING_UNTARGET_REGIONcxx . . $ `gtk/roaring/roaring.h:364:9`! _Pragma("clang attribute pop")
365 #elif defined(__GNUC__)
366 // GCC is easier
367 #define CROARING_TARGET_REGION(T) \
368 _Pragma("GCC push_options") _Pragma(STRINGIFY(GCC target(T)))
369 #define CROARING_UNTARGET_REGION _Pragma("GCC pop_options")
370 #endif // clang then gcc
371
372 #endif // CROARING_IS_X64
373
374 // Default target region macros don't do anything.
375 #ifndef CROARING_TARGET_REGIONcxx . . $ `gtk/roaring/roaring.h:361:9`!
376 #define CROARING_TARGET_REGION(T)
377 #define CROARING_UNTARGET_REGION
378 #endif
379
380 #define CROARING_TARGET_AVX2cxx . . $ `gtk/roaring/roaring.h:380:9`! \
381 CROARING_TARGET_REGIONcxx . . $ `gtk/roaring/roaring.h:361:9`!("avx2,bmi,pclmul,lzcnt,popcnt")
382 #define CROARING_TARGET_AVX512cxx . . $ `gtk/roaring/roaring.h:382:9`! \
383 CROARING_TARGET_REGIONcxx . . $ `gtk/roaring/roaring.h:361:9`!( \
384 "avx2,bmi,bmi2,pclmul,lzcnt,popcnt,avx512f,avx512dq,avx512bw," \
385 "avx512vbmi2,avx512bitalg,avx512vpopcntdq")
386 #define CROARING_UNTARGET_AVX2cxx . . $ `gtk/roaring/roaring.h:386:9`! CROARING_UNTARGET_REGIONcxx . . $ `gtk/roaring/roaring.h:364:9`!
387 #define CROARING_UNTARGET_AVX512cxx . . $ `gtk/roaring/roaring.h:387:9`! CROARING_UNTARGET_REGIONcxx . . $ `gtk/roaring/roaring.h:364:9`!
388
389 #ifdef __AVX2__
390 // No need for runtime dispatching.
391 // It is unnecessary and harmful to old clang to tag regions.
392 #undef CROARING_TARGET_AVX2
393 #define CROARING_TARGET_AVX2
394 #undef CROARING_UNTARGET_AVX2
395 #define CROARING_UNTARGET_AVX2
396 #endif
397
398 #if defined(__AVX512F__) && defined(__AVX512DQ__) && defined(__AVX512BW__) && \
399 defined(__AVX512VBMI2__) && defined(__AVX512BITALG__) && \
400 defined(__AVX512VPOPCNTDQ__)
401 // No need for runtime dispatching.
402 // It is unnecessary and harmful to old clang to tag regions.
403 #undef CROARING_TARGET_AVX512
404 #define CROARING_TARGET_AVX512
405 #undef CROARING_UNTARGET_AVX512
406 #define CROARING_UNTARGET_AVX512
407 #endif
408
409 // Allow unaligned memory access
410 #if defined(__GNUC__cxx . . $ `<built-in>:8:9`!) || defined(__clang__cxx . . $ `<built-in>:3:9`!)
411 #define ALLOW_UNALIGNEDcxx . . $ `gtk/roaring/roaring.h:411:9`! __attribute__((no_sanitize("alignment")))
412 #else
413 #define ALLOW_UNALIGNED
414 #endif
415
416 #if defined(__BYTE_ORDER__cxx . . $ `<built-in>:48:9`!) && defined(__ORDER_BIG_ENDIAN__cxx . . $ `<built-in>:46:9`!)
417 #define CROARING_IS_BIG_ENDIANcxx . . $ `gtk/roaring/roaring.h:417:9`! (__BYTE_ORDER__cxx . . $ `<built-in>:48:9`! == __ORDER_BIG_ENDIAN__cxx . . $ `<built-in>:46:9`!)
418 #elif defined(_WIN32)
419 #define CROARING_IS_BIG_ENDIAN 0
420 #else
421 #if defined(__APPLE__) || \
422 defined(__FreeBSD__) // defined __BYTE_ORDER__ && defined
423 // __ORDER_BIG_ENDIAN__
424 #include <machine/endian.h>
425 #elif defined(sun) || \
426 defined(__sun) // defined(__APPLE__) || defined(__FreeBSD__)
427 #include <sys/byteorder.h>
428 #else // defined(__APPLE__) || defined(__FreeBSD__)
429
430 #ifdef __has_include
431 #if __has_include(<endian.h>)
432 #include <endian.h>
433 #endif //__has_include(<endian.h>)
434 #endif //__has_include
435
436 #endif // defined(__APPLE__) || defined(__FreeBSD__)
437
438 #ifndef !defined(__BYTE_ORDER__) || !defined(__ORDER_LITTLE_ENDIAN__)
439 #define CROARING_IS_BIG_ENDIAN 0
440 #endif
441
442 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
443 #define CROARING_IS_BIG_ENDIAN 0
444 #else // __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
445 #define CROARING_IS_BIG_ENDIAN 1
446 #endif // __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
447 #endif
448
449 // Host <-> big endian conversion.
450 #if CROARING_IS_BIG_ENDIANcxx . . $ `gtk/roaring/roaring.h:417:9`!
451 #define croaring_htobe64(x) (x)
452
453 #elif defined(_WIN32) || defined(_WIN64) // CROARING_IS_BIG_ENDIAN
454 #include <stdlib.h>
455 #define croaring_htobe64(x) _byteswap_uint64(x)
456
457 #elif defined(__APPLE__) // CROARING_IS_BIG_ENDIAN
458 #include <libkern/OSByteOrder.h>
459 #define croaring_htobe64(x) OSSwapInt64(x)
460
461 #elif defined(__has_include) && \
462 __has_include( \
463 <byteswap.h>) && (defined(__linux__cxx . . $ `<built-in>:398:9`!) || defined(__FreeBSD__)) // CROARING_IS_BIG_ENDIAN
464 #include <byteswap.h>
465 #if defined(__linux__cxx . . $ `<built-in>:398:9`!)
466 #define croaring_htobe64cxx . . $ `gtk/roaring/roaring.h:466:9`!(x) bswap_64cxx . . $ `<external>/11871147157791630944/byteswap.h:38:9`!(x)
467 #elif defined(__FreeBSD__)
468 #define croaring_htobe64(x) bswap64(x)
469 #else
470 #warning "Unknown platform, report as an error"
471 #endif
472
473 #else // CROARING_IS_BIG_ENDIAN
474 // Gets compiled to bswap or equivalent on most compilers.
475 #define croaring_htobe64(x) \
476 (((x & 0x00000000000000FFULL) << 56) | \
477 ((x & 0x000000000000FF00ULL) << 40) | \
478 ((x & 0x0000000000FF0000ULL) << 24) | \
479 ((x & 0x00000000FF000000ULL) << 8) | ((x & 0x000000FF00000000ULL) >> 8) | \
480 ((x & 0x0000FF0000000000ULL) >> 24) | \
481 ((x & 0x00FF000000000000ULL) >> 40) | \
482 ((x & 0xFF00000000000000ULL) >> 56))
483 #endif // CROARING_IS_BIG_ENDIAN
484 #define croaring_be64tohcxx . . $ `gtk/roaring/roaring.h:484:9`!(x) croaring_htobe64cxx . . $ `gtk/roaring/roaring.h:466:9`!(x)
485 // End of host <-> big endian conversion.
486
487 // Defines for the possible CROARING atomic implementations
488 #define CROARING_ATOMIC_IMPL_NONEcxx . . $ `gtk/roaring/roaring.h:488:9`! 1
489 #define CROARING_ATOMIC_IMPL_CPPcxx . . $ `gtk/roaring/roaring.h:489:9`! 2
490 #define CROARING_ATOMIC_IMPL_Ccxx . . $ `gtk/roaring/roaring.h:490:9`! 3
491 #define CROARING_ATOMIC_IMPL_C_WINDOWScxx . . $ `gtk/roaring/roaring.h:491:9`! 4
492
493 // If the use has forced a specific implementation, use that, otherwise,
494 // figure out the best implementation we can use.
495 #if !defined(CROARING_ATOMIC_IMPL)
496 #if defined(__cplusplus) && __cplusplus >= 201103L
497 #ifdef __has_include
498 #if __has_include(<atomic>)
499 #define CROARING_ATOMIC_IMPL CROARING_ATOMIC_IMPL_CPP
500 #endif //__has_include(<atomic>)
501 #else
502 // We lack __has_include to check:
503 #define CROARING_ATOMIC_IMPL CROARING_ATOMIC_IMPL_CPP
504 #endif //__has_include
505 #elif __STDC_VERSION__cxx . . $ `<built-in>:404:9`! >= 201112L && !defined(__STDC_NO_ATOMICS__)
506 #define CROARING_ATOMIC_IMPLcxx . . $ `gtk/roaring/roaring.h:506:9`! CROARING_ATOMIC_IMPL_Ccxx . . $ `gtk/roaring/roaring.h:490:9`!
507 #elif CROARING_REGULAR_VISUAL_STUDIO
508 // https://www.technetworkhub.com/c11-atomics-in-visual-studio-2022-version-17/
509 #define CROARING_ATOMIC_IMPL CROARING_ATOMIC_IMPL_C_WINDOWS
510 #endif
511 #endif // !defined(CROARING_ATOMIC_IMPL)
512
513 #if CROARING_ATOMIC_IMPLcxx . . $ `gtk/roaring/roaring.h:506:9`! == CROARING_ATOMIC_IMPL_Ccxx . . $ `gtk/roaring/roaring.h:490:9`!
514 #include <stdatomic.h>
515 typedef _Atomic(uint32_tcxx . . $ uint32_t#) croaring_refcount_tcxx . . $ croaring_refcount_t#;
516
517 static inline void croaring_refcount_inccxx . . $ croaring_refcount_inc(95162b8e33225393).(croaring_refcount_tcxx . . $ croaring_refcount_t# *val) {
518 // Increasing the reference counter can always be done with
519 // memory_order_relaxed: New references to an object can only be formed from
520 // an existing reference, and passing an existing reference from one thread
521 // to another must already provide any required synchronization.
522 atomic_fetch_add_explicitcxx . . $ `<external>/6975296586547049691/stdatomic.h:202:9`!(val, 1, memory_order_relaxed);
523 }
524
525 static inline boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! croaring_refcount_deccxx . . $ croaring_refcount_dec(bee78a45e0232125).(croaring_refcount_tcxx . . $ croaring_refcount_t# *val) {
526 // It is important to enforce any possible access to the object in one
527 // thread (through an existing reference) to happen before deleting the
528 // object in a different thread. This is achieved by a "release" operation
529 // after dropping a reference (any access to the object through this
530 // reference must obviously happened before), and an "acquire" operation
531 // before deleting the object.
532 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! is_zero = atomic_fetch_sub_explicitcxx . . $ memory_order_release.(val, 1, memory_order_release) == 1;
533 if (is_zero) {
534 atomic_thread_fencecxx . . $ `<external>/6975296586547049691/stdatomic.h:98:9`!(memory_order_acquire);
535 }
536 return is_zero;
537 }
538
539 static inline uint32_tcxx . . $ uint32_t# croaring_refcount_getcxx . . $ croaring_refcount_get(7ae49d8158fcf743).(const croaring_refcount_tcxx . . $ croaring_refcount_t# *val) {
540 return atomic_load_explicitcxx . . $ memory_order_relaxed.(val, memory_order_relaxed);
541 }
542 #elif CROARING_ATOMIC_IMPL == CROARING_ATOMIC_IMPL_CPP
543 #include <atomic>
544 typedef std::atomic<uint32_t> croaring_refcount_t;
545
546 static inline void croaring_refcount_inc(croaring_refcount_t *val) {
547 val->fetch_add(1, std::memory_order_relaxed);
548 }
549
550 static inline bool croaring_refcount_dec(croaring_refcount_t *val) {
551 // See above comments on the c11 atomic implementation for memory ordering
552 bool is_zero = val->fetch_sub(1, std::memory_order_release) == 1;
553 if (is_zero) {
554 std::atomic_thread_fence(std::memory_order_acquire);
555 }
556 return is_zero;
557 }
558
559 static inline uint32_t croaring_refcount_get(const croaring_refcount_t *val) {
560 return val->load(std::memory_order_relaxed);
561 }
562 #elif CROARING_ATOMIC_IMPL == CROARING_ATOMIC_IMPL_C_WINDOWS
563 #include <intrin.h>
564 #pragma intrinsic(_InterlockedIncrement)
565 #pragma intrinsic(_InterlockedDecrement)
566
567 // _InterlockedIncrement and _InterlockedDecrement take a (signed) long, and
568 // overflow is defined to wrap, so we can pretend it is a uint32_t for our case
569 typedef volatile long croaring_refcount_t;
570
571 static inline void croaring_refcount_inc(croaring_refcount_t *val) {
572 _InterlockedIncrement(val);
573 }
574
575 static inline bool croaring_refcount_dec(croaring_refcount_t *val) {
576 return _InterlockedDecrement(val) == 0;
577 }
578
579 static inline uint32_t croaring_refcount_get(const croaring_refcount_t *val) {
580 // Per
581 // https://learn.microsoft.com/en-us/windows/win32/sync/interlocked-variable-access
582 // > Simple reads and writes to properly-aligned 32-bit variables are atomic
583 // > operations. In other words, you will not end up with only one portion
584 // > of the variable updated; all bits are updated in an atomic fashion.
585 return *val;
586 }
587 #elif CROARING_ATOMIC_IMPL == CROARING_ATOMIC_IMPL_NONE
588 #include <assert.h>
589 typedef uint32_t croaring_refcount_t;
590
591 static inline void croaring_refcount_inc(croaring_refcount_t *val) {
592 *val += 1;
593 }
594
595 static inline bool croaring_refcount_dec(croaring_refcount_t *val) {
596 assert(*val > 0);
597 *val -= 1;
598 return val == 0;
599 }
600
601 static inline uint32_t croaring_refcount_get(const croaring_refcount_t *val) {
602 return *val;
603 }
604 #else
605 #error "Unknown atomic implementation"
606 #endif
607
608 #if defined(__GNUC__cxx . . $ `<built-in>:8:9`!) || defined(__clang__cxx . . $ `<built-in>:3:9`!)
609 #define CROARING_DEPRECATEDcxx . . $ `gtk/roaring/roaring.h:609:9`! __attribute__((deprecated))
610 #elif defined(_MSC_VER)
611 #define CROARING_DEPRECATED __declspec(deprecated)
612 #else
613 #define CROARING_DEPRECATED
614 #endif // defined(__GNUC__) || defined(__clang__)
615
616 // We want to initialize structs to zero portably (C and C++), without
617 // warnings. We can do mystruct s = CROARING_ZERO_INITIALIZER;
618 #ifdef __cplusplus
619 #define CROARING_ZERO_INITIALIZER \
620 {}
621 #else
622 #define CROARING_ZERO_INITIALIZERcxx . . $ `gtk/roaring/roaring.h:622:9`! \
623 { 0 }
624 #endif
625
626 #if defined(__cplusplus)
627 #define CROARING_STATIC_ASSERT(x, y) static_assert(x, y)
628 #else
629 #define CROARING_STATIC_ASSERTcxx . . $ `gtk/roaring/roaring.h:629:9`!(x, y) _Static_assert(x, y)
630 #endif
631
632 // We need portability.h to be included first,
633 // but we also always want isadetection.h to be
634 // included (right after).
635 // See https://github.com/RoaringBitmap/CRoaring/issues/394
636 // There is no scenario where we want portability.h to
637 // be included, but not isadetection.h: the latter is a
638 // strict requirement.
639 #endif /* INCLUDE_PORTABILITY_H_ */
640 /* end file include/roaring/portability.h */
641 /* begin file include/roaring/roaring_types.h */
642 /*
643 Typedefs used by various components
644 */
645
646 #ifndef ROARING_TYPES_Hcxx . . $ `gtk/roaring/roaring.h:647:9`!
647 #define ROARING_TYPES_Hcxx . . $ `gtk/roaring/roaring.h:647:9`!
648
649 #include <stdbool.h>
650 #include <stdint.h>
651
652
653 #ifdef __cplusplus
654 extern "C" {
655 namespace roaring {
656 namespace api {
657 #endif
658
659 /**
660 * When building .c files as C++, there's added compile-time checking if the
661 * container types are derived from a `container_t` base class. So long as
662 * such a base class is empty, the struct will behave compatibly with C structs
663 * despite the derivation. This is due to the Empty Base Class Optimization:
664 *
665 * https://en.cppreference.com/w/cpp/language/ebo
666 *
667 * But since C isn't namespaced, taking `container_t` globally might collide
668 * with other projects. So roaring.h uses ROARING_CONTAINER_T, while internal
669 * code #undefs that after declaring `typedef ROARING_CONTAINER_T container_t;`
670 */
671 #if defined(__cplusplus)
672 extern "C++" {
673 struct container_s {};
674 }
675 #define ROARING_CONTAINER_T ::roaring::api::container_s
676 #else
677 #define ROARING_CONTAINER_Tcxx . . $ `gtk/roaring/roaring.h:677:9`! void // no compile-time checking
678 #endif
679
680 #define ROARING_FLAG_COWcxx . . $ `gtk/roaring/roaring.h:680:9`! UINT8_Ccxx . . $ `<external>/3415975807581488833/stdint.h:247:10`!(0x1)
681 #define ROARING_FLAG_FROZENcxx . . $ `gtk/roaring/roaring.h:681:9`! UINT8_Ccxx . . $ `<external>/3415975807581488833/stdint.h:247:10`!(0x2)
682
683 /**
684 * Roaring arrays are array-based key-value pairs having containers as values
685 * and 16-bit integer keys. A roaring bitmap might be implemented as such.
686 */
687
688 // parallel arrays. Element sizes quite different.
689 // Alternative is array
690 // of structs. Which would have better
691 // cache performance through binary searches?
692
693 typedef struct roaring_array_scxx . . $ roaring_array_s# {
694 int32_tcxx . . $ int32_t# sizecxx . . $ roaring_array_s#size.;
695 int32_tcxx . . $ int32_t# allocation_sizecxx . . $ roaring_array_s#allocation_size.;
696 ROARING_CONTAINER_Tcxx . . $ `gtk/roaring/roaring.h:677:9`! **containerscxx . . $ roaring_array_s#containers.; // Use container_t in non-API files!
697 uint16_tcxx . . $ uint16_t# *keyscxx . . $ roaring_array_s#keys.;
698 uint8_tcxx . . $ uint8_t# *typecodescxx . . $ roaring_array_s#typecodes.;
699 uint8_tcxx . . $ uint8_t# flagscxx . . $ roaring_array_s#flags.;
700 } roaring_array_tcxx . . $ roaring_array_t#;
701
702 typedef boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! (*roaring_iteratorcxx . . $ roaring_iterator#)(uint32_tcxx . . $ uint32_t# value, void *param);
703 typedef boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! (*roaring_iterator64cxx . . $ roaring_iterator64#)(uint64_tcxx . . $ uint64_t# value, void *param);
704
705 /**
706 * (For advanced users.)
707 * The roaring_statistics_t can be used to collect detailed statistics about
708 * the composition of a roaring bitmap.
709 */
710 typedef struct roaring_statistics_scxx . . $ roaring_statistics_s# {
711 uint32_tcxx . . $ uint32_t# n_containerscxx . . $ roaring_statistics_s#n_containers.; /* number of containers */
712
713 uint32_tcxx . . $ uint32_t# n_array_containerscxx . . $ roaring_statistics_s#n_array_containers.; /* number of array containers */
714 uint32_tcxx . . $ uint32_t# n_run_containerscxx . . $ roaring_statistics_s#n_run_containers.; /* number of run containers */
715 uint32_tcxx . . $ uint32_t# n_bitset_containerscxx . . $ roaring_statistics_s#n_bitset_containers.; /* number of bitmap containers */
716
717 uint32_tcxx . . $ uint32_t#
718 n_values_array_containerscxx . . $ roaring_statistics_s#n_values_array_containers.; /* number of values in array containers */
719 uint32_tcxx . . $ uint32_t# n_values_run_containerscxx . . $ roaring_statistics_s#n_values_run_containers.; /* number of values in run containers */
720 uint32_tcxx . . $ uint32_t#
721 n_values_bitset_containerscxx . . $ roaring_statistics_s#n_values_bitset_containers.; /* number of values in bitmap containers */
722
723 uint32_tcxx . . $ uint32_t# n_bytes_array_containerscxx . . $ roaring_statistics_s#n_bytes_array_containers.; /* number of allocated bytes in array
724 containers */
725 uint32_tcxx . . $ uint32_t# n_bytes_run_containerscxx . . $ roaring_statistics_s#n_bytes_run_containers.; /* number of allocated bytes in run
726 containers */
727 uint32_tcxx . . $ uint32_t# n_bytes_bitset_containerscxx . . $ roaring_statistics_s#n_bytes_bitset_containers.; /* number of allocated bytes in bitmap
728 containers */
729
730 uint32_tcxx . . $ uint32_t#
731 max_valuecxx . . $ roaring_statistics_s#max_value.; /* the maximal value, undefined if cardinality is zero */
732 uint32_tcxx . . $ uint32_t#
733 min_valuecxx . . $ roaring_statistics_s#min_value.; /* the minimal value, undefined if cardinality is zero */
734
735 CROARING_DEPRECATEDcxx . . $ `gtk/roaring/roaring.h:609:9`!
736 uint64_tcxx . . $ uint64_t# sum_valuecxx . . $ roaring_statistics_s#sum_value.; /* deprecated always zero */
737
738 uint64_tcxx . . $ uint64_t# cardinalitycxx . . $ roaring_statistics_s#cardinality.; /* total number of values stored in the bitmap */
739
740 // and n_values_arrays, n_values_rle, n_values_bitmap
741 } roaring_statistics_tcxx . . $ roaring_statistics_t#;
742
743 /**
744 * (For advanced users.)
745 * The roaring64_statistics_t can be used to collect detailed statistics about
746 * the composition of a roaring64 bitmap.
747 */
748 typedef struct roaring64_statistics_scxx . . $ roaring64_statistics_s# {
749 uint64_tcxx . . $ uint64_t# n_containerscxx . . $ roaring64_statistics_s#n_containers.; /* number of containers */
750
751 uint64_tcxx . . $ uint64_t# n_array_containerscxx . . $ roaring64_statistics_s#n_array_containers.; /* number of array containers */
752 uint64_tcxx . . $ uint64_t# n_run_containerscxx . . $ roaring64_statistics_s#n_run_containers.; /* number of run containers */
753 uint64_tcxx . . $ uint64_t# n_bitset_containerscxx . . $ roaring64_statistics_s#n_bitset_containers.; /* number of bitmap containers */
754
755 uint64_tcxx . . $ uint64_t#
756 n_values_array_containerscxx . . $ roaring64_statistics_s#n_values_array_containers.; /* number of values in array containers */
757 uint64_tcxx . . $ uint64_t# n_values_run_containerscxx . . $ roaring64_statistics_s#n_values_run_containers.; /* number of values in run containers */
758 uint64_tcxx . . $ uint64_t#
759 n_values_bitset_containerscxx . . $ roaring64_statistics_s#n_values_bitset_containers.; /* number of values in bitmap containers */
760
761 uint64_tcxx . . $ uint64_t# n_bytes_array_containerscxx . . $ roaring64_statistics_s#n_bytes_array_containers.; /* number of allocated bytes in array
762 containers */
763 uint64_tcxx . . $ uint64_t# n_bytes_run_containerscxx . . $ roaring64_statistics_s#n_bytes_run_containers.; /* number of allocated bytes in run
764 containers */
765 uint64_tcxx . . $ uint64_t# n_bytes_bitset_containerscxx . . $ roaring64_statistics_s#n_bytes_bitset_containers.; /* number of allocated bytes in bitmap
766 containers */
767
768 uint64_tcxx . . $ uint64_t#
769 max_valuecxx . . $ roaring64_statistics_s#max_value.; /* the maximal value, undefined if cardinality is zero */
770 uint64_tcxx . . $ uint64_t#
771 min_valuecxx . . $ roaring64_statistics_s#min_value.; /* the minimal value, undefined if cardinality is zero */
772
773 uint64_tcxx . . $ uint64_t# cardinalitycxx . . $ roaring64_statistics_s#cardinality.; /* total number of values stored in the bitmap */
774
775 // and n_values_arrays, n_values_rle, n_values_bitmap
776 } roaring64_statistics_tcxx . . $ roaring64_statistics_t#;
777
778 /**
779 * Roaring-internal type used to iterate within a roaring container.
780 */
781 typedef struct roaring_container_iterator_scxx . . $ roaring_container_iterator_s# {
782 // For bitset and array containers this is the index of the bit / entry.
783 // For run containers this points at the run.
784 int32_tcxx . . $ int32_t# indexcxx . . $ roaring_container_iterator_s#index.;
785 } roaring_container_iterator_tcxx . . $ roaring_container_iterator_t#;
786
787 #ifdef __cplusplus
788 }
789 }
790 } // extern "C" { namespace roaring { namespace api {
791 #endif
792
793 #endif /* ROARING_TYPES_H */
794 /* end file include/roaring/roaring_types.h */
795 /* begin file include/roaring/bitset/bitset.h */
796 #ifndef CROARING_CBITSET_BITSET_Hcxx . . $ `gtk/roaring/roaring.h:797:9`!
797 #define CROARING_CBITSET_BITSET_Hcxx . . $ `gtk/roaring/roaring.h:797:9`!
798
799 // For compatibility with MSVC with the use of `restrict`
800 #if (__STDC_VERSION__cxx . . $ `<built-in>:404:9`! >= 199901L) || \
801 (defined(__GNUC__cxx . . $ `<built-in>:8:9`!) && defined(__STDC_VERSION__cxx . . $ `<built-in>:404:9`!))
802 #define CROARING_CBITSET_RESTRICTcxx . . $ `gtk/roaring/roaring.h:802:9`! restrict
803 #else
804 #define CROARING_CBITSET_RESTRICT
805 #endif // (__STDC_VERSION__ >= 199901L) || (defined(__GNUC__) &&
806 // defined(__STDC_VERSION__ ))
807
808 #include <stdbool.h>
809 #include <stdint.h>
810 #include <stdio.h>
811 #include <stdlib.h>
812 #include <string.h>
813
814
815 #ifdef __cplusplus
816 extern "C" {
817 namespace roaring {
818 namespace api {
819 #endif
820
821 struct bitset_scxx . . $ bitset_s# {
822 uint64_tcxx . . $ uint64_t# *CROARING_CBITSET_RESTRICTcxx . . $ `gtk/roaring/roaring.h:802:9`! arraycxx . . $ bitset_s#array.;
823 /* For simplicity and performance, we prefer to have a size and a capacity
824 * that is a multiple of 64 bits. Thus we only track the size and the
825 * capacity in terms of 64-bit words allocated */
826 size_t arraysizecxx . . $ bitset_s#arraysize.;
827 size_t capacitycxx . . $ bitset_s#capacity.;
828 };
829
830 typedef struct bitset_scxx . . $ bitset_s# bitset_tcxx . . $ bitset_t#;
831
832 /* Create a new bitset. Return NULL in case of failure. */
833 static bitset_tcxx . . $ bitset_t# *bitset_createcxx . . $ bitset_create(c484c03b20115bd7).(void);
834
835 /* Create a new bitset able to contain size bits. Return NULL in case of
836 * failure. */
837 static bitset_tcxx . . $ bitset_t# *bitset_create_with_capacitycxx . . $ bitset_create_with_capacity(7d39cecd846261d6).(size_t size);
838
839 /* Free memory. */
840 static void bitset_freecxx . . $ bitset_free(1f2d0be879fb1477).(bitset_tcxx . . $ bitset_t# *bitset);
841
842 /* Set all bits to zero. */
843 static void bitset_clearcxx . . $ bitset_clear(1f2d0be879fb1477).(bitset_tcxx . . $ bitset_t# *bitset);
844
845 /* Set all bits to one. */
846 static void bitset_fillcxx . . $ bitset_fill(1f2d0be879fb1477).(bitset_tcxx . . $ bitset_t# *bitset);
847
848 /* Create a copy */
849 static bitset_tcxx . . $ bitset_t# *bitset_copycxx . . $ bitset_copy(89f898aee1c7ad14).(const bitset_tcxx . . $ bitset_t# *bitset);
850
851 /* For advanced users: Resize the bitset so that it can support newarraysize *
852 * 64 bits. Return true in case of success, false for failure. Pad with zeroes
853 * new buffer areas if requested. */
854 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! bitset_resizecxx . . $ bitset_resize(31233a5326388a3f).(bitset_tcxx . . $ bitset_t# *bitset, size_t newarraysize, boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! padwithzeroes);
855
856 /* returns how many bytes of memory the backend buffer uses */
857 static inline size_t bitset_size_in_bytescxx . . $ bitset_size_in_bytes(c87c563e57245a70).(const bitset_tcxx . . $ bitset_t# *bitset) {
858 return bitset->arraysizecxx . . $ bitset_s#arraysize. * sizeof(uint64_tcxx . . $ uint64_t#);
859 }
860
861 /* returns how many bits can be accessed */
862 static inline size_t bitset_size_in_bitscxx . . $ bitset_size_in_bits(c87c563e57245a70).(const bitset_tcxx . . $ bitset_t# *bitset) {
863 return bitset->arraysizecxx . . $ bitset_s#arraysize. * 64;
864 }
865
866 /* returns how many words (64-bit) of memory the backend buffer uses */
867 static inline size_t bitset_size_in_wordscxx . . $ bitset_size_in_words(c87c563e57245a70).(const bitset_tcxx . . $ bitset_t# *bitset) {
868 return bitset->arraysizecxx . . $ bitset_s#arraysize.;
869 }
870
871 /* For advanced users: Grow the bitset so that it can support newarraysize * 64
872 * bits with padding. Return true in case of success, false for failure. */
873 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! bitset_growcxx . . $ bitset_grow(e59c538ba289e427).(bitset_tcxx . . $ bitset_t# *bitset, size_t newarraysize);
874
875 /* attempts to recover unused memory, return false in case of
876 * roaring_reallocation failure */
877 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! bitset_trimcxx . . $ bitset_trim(272fdc1853ed30f8).(bitset_tcxx . . $ bitset_t# *bitset);
878
879 /* shifts all bits by 's' positions so that the bitset representing values
880 * 1,2,10 would represent values 1+s, 2+s, 10+s */
881 static void bitset_shift_leftcxx . . $ bitset_shift_left(bd8e4f95ff65ba88).(bitset_tcxx . . $ bitset_t# *bitset, size_t s);
882
883 /* shifts all bits by 's' positions so that the bitset representing values
884 * 1,2,10 would represent values 1-s, 2-s, 10-s, negative values are deleted */
885 static void bitset_shift_rightcxx . . $ bitset_shift_right(bd8e4f95ff65ba88).(bitset_tcxx . . $ bitset_t# *bitset, size_t s);
886
887 /* Set the ith bit. Attempts to resize the bitset if needed (may silently fail)
888 */
889 static inline void bitset_setcxx . . $ bitset_set(bd8e4f95ff65ba88).(bitset_tcxx . . $ bitset_t# *bitset, size_t i) {
890 size_t shiftedi = i / 64;
891 if (shiftedi >= bitset->arraysizecxx . . $ bitset_s#arraysize.) {
892 if (!bitset_growcxx . . $ bitset_grow(e59c538ba289e427).(bitset, shiftedi + 1)) {
893 return;
894 }
895 }
896 bitset->arraycxx . . $ bitset_s#array.[shiftedi] |= ((uint64_tcxx . . $ uint64_t#)1) << (i % 64);
897 }
898
899 /* Set the ith bit to the specified value. Attempts to resize the bitset if
900 * needed (may silently fail) */
901 static inline void bitset_set_to_valuecxx . . $ bitset_set_to_value(1ccb6014772ecf22).(bitset_tcxx . . $ bitset_t# *bitset, size_t i, boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! flag) {
902 size_t shiftedi = i / 64;
903 uint64_tcxx . . $ uint64_t# mask = ((uint64_tcxx . . $ uint64_t#)1) << (i % 64);
904 uint64_tcxx . . $ uint64_t# dynmask = ((uint64_tcxx . . $ uint64_t#)flag) << (i % 64);
905 if (shiftedi >= bitset->arraysizecxx . . $ bitset_s#arraysize.) {
906 if (!bitset_growcxx . . $ bitset_grow(e59c538ba289e427).(bitset, shiftedi + 1)) {
907 return;
908 }
909 }
910 uint64_tcxx . . $ uint64_t# w = bitset->arraycxx . . $ bitset_s#array.[shiftedi];
911 w &= ~mask;
912 w |= dynmask;
913 bitset->arraycxx . . $ bitset_s#array.[shiftedi] = w;
914 }
915
916 /* Get the value of the ith bit. */
917 static inline boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! bitset_getcxx . . $ bitset_get(31f462f957cbb389).(const bitset_tcxx . . $ bitset_t# *bitset, size_t i) {
918 size_t shiftedi = i / 64;
919 if (shiftedi >= bitset->arraysizecxx . . $ bitset_s#arraysize.) {
920 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
921 }
922 return (bitset->arraycxx . . $ bitset_s#array.[shiftedi] & (((uint64_tcxx . . $ uint64_t#)1) << (i % 64))) != 0;
923 }
924
925 /* Count number of bits set. */
926 static size_t bitset_countcxx . . $ bitset_count(c87c563e57245a70).(const bitset_tcxx . . $ bitset_t# *bitset);
927
928 /* Returns true if no bit is set. */
929 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! bitset_emptycxx . . $ bitset_empty(658672f4dc2221ac).(const bitset_tcxx . . $ bitset_t# *bitset);
930
931 /* Find the index of the first bit set. Or SIZE_MAX if the bitset is empty. */
932 static size_t bitset_minimumcxx . . $ bitset_minimum(c87c563e57245a70).(const bitset_tcxx . . $ bitset_t# *bitset);
933
934 /* Find the index of the last bit set. Or zero if the bitset is empty. */
935 static size_t bitset_maximumcxx . . $ bitset_maximum(c87c563e57245a70).(const bitset_tcxx . . $ bitset_t# *bitset);
936
937 /* compute the union in-place (to b1), returns true if successful, to generate a
938 * new bitset first call bitset_copy */
939 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! bitset_inplace_unioncxx . . $ bitset_inplace_union(d9d504f436067ce0).(bitset_tcxx . . $ bitset_t# *CROARING_CBITSET_RESTRICTcxx . . $ `gtk/roaring/roaring.h:802:9`! b1,
940 const bitset_tcxx . . $ bitset_t# *CROARING_CBITSET_RESTRICTcxx . . $ `gtk/roaring/roaring.h:802:9`! b2);
941
942 /* report the size of the union (without materializing it) */
943 static size_t bitset_union_countcxx . . $ bitset_union_count(76971e50b8a72a64).(const bitset_tcxx . . $ bitset_t# *CROARING_CBITSET_RESTRICTcxx . . $ `gtk/roaring/roaring.h:802:9`! b1,
944 const bitset_tcxx . . $ bitset_t# *CROARING_CBITSET_RESTRICTcxx . . $ `gtk/roaring/roaring.h:802:9`! b2);
945
946 /* compute the intersection in-place (to b1), to generate a new bitset first
947 * call bitset_copy */
948 static void bitset_inplace_intersectioncxx . . $ bitset_inplace_intersection(22a8880da5abdaa4).(bitset_tcxx . . $ bitset_t# *CROARING_CBITSET_RESTRICTcxx . . $ `gtk/roaring/roaring.h:802:9`! b1,
949 const bitset_tcxx . . $ bitset_t# *CROARING_CBITSET_RESTRICTcxx . . $ `gtk/roaring/roaring.h:802:9`! b2);
950
951 /* report the size of the intersection (without materializing it) */
952 static size_t bitset_intersection_countcxx . . $ bitset_intersection_count(76971e50b8a72a64).(const bitset_tcxx . . $ bitset_t# *CROARING_CBITSET_RESTRICTcxx . . $ `gtk/roaring/roaring.h:802:9`! b1,
953 const bitset_tcxx . . $ bitset_t# *CROARING_CBITSET_RESTRICTcxx . . $ `gtk/roaring/roaring.h:802:9`! b2);
954
955 /* returns true if the bitsets contain no common elements */
956 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! bitsets_disjointcxx . . $ bitsets_disjoint(2ff8fecaa69dcbd6).(const bitset_tcxx . . $ bitset_t# *CROARING_CBITSET_RESTRICTcxx . . $ `gtk/roaring/roaring.h:802:9`! b1,
957 const bitset_tcxx . . $ bitset_t# *CROARING_CBITSET_RESTRICTcxx . . $ `gtk/roaring/roaring.h:802:9`! b2);
958
959 /* returns true if the bitsets contain any common elements */
960 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! bitsets_intersectcxx . . $ bitsets_intersect(2ff8fecaa69dcbd6).(const bitset_tcxx . . $ bitset_t# *CROARING_CBITSET_RESTRICTcxx . . $ `gtk/roaring/roaring.h:802:9`! b1,
961 const bitset_tcxx . . $ bitset_t# *CROARING_CBITSET_RESTRICTcxx . . $ `gtk/roaring/roaring.h:802:9`! b2);
962
963 /* returns true if b1 contains all of the set bits of b2 */
964 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! bitset_contains_allcxx . . $ bitset_contains_all(2ff8fecaa69dcbd6).(const bitset_tcxx . . $ bitset_t# *CROARING_CBITSET_RESTRICTcxx . . $ `gtk/roaring/roaring.h:802:9`! b1,
965 const bitset_tcxx . . $ bitset_t# *CROARING_CBITSET_RESTRICTcxx . . $ `gtk/roaring/roaring.h:802:9`! b2);
966
967 /* compute the difference in-place (to b1), to generate a new bitset first call
968 * bitset_copy */
969 static void bitset_inplace_differencecxx . . $ bitset_inplace_difference(22a8880da5abdaa4).(bitset_tcxx . . $ bitset_t# *CROARING_CBITSET_RESTRICTcxx . . $ `gtk/roaring/roaring.h:802:9`! b1,
970 const bitset_tcxx . . $ bitset_t# *CROARING_CBITSET_RESTRICTcxx . . $ `gtk/roaring/roaring.h:802:9`! b2);
971
972 /* compute the size of the difference */
973 static size_t bitset_difference_countcxx . . $ bitset_difference_count(76971e50b8a72a64).(const bitset_tcxx . . $ bitset_t# *CROARING_CBITSET_RESTRICTcxx . . $ `gtk/roaring/roaring.h:802:9`! b1,
974 const bitset_tcxx . . $ bitset_t# *CROARING_CBITSET_RESTRICTcxx . . $ `gtk/roaring/roaring.h:802:9`! b2);
975
976 /* compute the symmetric difference in-place (to b1), return true if successful,
977 * to generate a new bitset first call bitset_copy */
978 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! bitset_inplace_symmetric_differencecxx . . $ bitset_inplace_symmetric_difference(d9d504f436067ce0).(
979 bitset_tcxx . . $ bitset_t# *CROARING_CBITSET_RESTRICTcxx . . $ `gtk/roaring/roaring.h:802:9`! b1,
980 const bitset_tcxx . . $ bitset_t# *CROARING_CBITSET_RESTRICTcxx . . $ `gtk/roaring/roaring.h:802:9`! b2);
981
982 /* compute the size of the symmetric difference */
983 static size_t bitset_symmetric_difference_countcxx . . $ bitset_symmetric_difference_count(76971e50b8a72a64).(
984 const bitset_tcxx . . $ bitset_t# *CROARING_CBITSET_RESTRICTcxx . . $ `gtk/roaring/roaring.h:802:9`! b1,
985 const bitset_tcxx . . $ bitset_t# *CROARING_CBITSET_RESTRICTcxx . . $ `gtk/roaring/roaring.h:802:9`! b2);
986
987 /* iterate over the set bits
988 like so :
989 for(size_t i = 0; bitset_next_set_bit(b,&i) ; i++) {
990 //.....
991 }
992 */
993 static inline boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! bitset_next_set_bitcxx . . $ bitset_next_set_bit(3dd7b76510ed14ff).(const bitset_tcxx . . $ bitset_t# *bitset, size_t *i) {
994 size_t x = *i / 64;
995 if (x >= bitset->arraysizecxx . . $ bitset_s#arraysize.) {
996 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
997 }
998 uint64_tcxx . . $ uint64_t# w = bitset->arraycxx . . $ bitset_s#array.[x];
999 w >>= (*i & 63);
1000 if (w != 0) {
1001 *i += roaring_trailing_zeroescxx . . $ roaring_trailing_zeroes(642c2e9948c4ad2).(w);
1002 return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1003 }
1004 x++;
1005 while (x < bitset->arraysizecxx . . $ bitset_s#arraysize.) {
1006 w = bitset->arraycxx . . $ bitset_s#array.[x];
1007 if (w != 0) {
1008 *i = x * 64 + roaring_trailing_zeroescxx . . $ roaring_trailing_zeroes(642c2e9948c4ad2).(w);
1009 return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1010 }
1011 x++;
1012 }
1013 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1014 }
1015
1016 /* iterate over the set bits
1017 like so :
1018 size_t buffer[256];
1019 size_t howmany = 0;
1020 for(size_t startfrom = 0; (howmany = bitset_next_set_bits(b,buffer,256,
1021 &startfrom)) > 0 ; startfrom++) {
1022 //.....
1023 }
1024 */
1025 static inline size_t bitset_next_set_bitscxx . . $ bitset_next_set_bits(7907a26ed04f66f).(const bitset_tcxx . . $ bitset_t# *bitset, size_t *buffer,
1026 size_t capacity, size_t *startfrom) {
1027 if (capacity == 0) return 0; // sanity check
1028 size_t x = *startfrom / 64;
1029 if (x >= bitset->arraysizecxx . . $ bitset_s#arraysize.) {
1030 return 0; // nothing more to iterate over
1031 }
1032 uint64_tcxx . . $ uint64_t# w = bitset->arraycxx . . $ bitset_s#array.[x];
1033 // unset low bits inside the word less than *startfrom
1034 w &= ~((UINT64_Ccxx . . $ `<external>/3415975807581488833/stdint.h:251:11`!(1) << (*startfrom & 63)) - 1);
1035 size_t howmany = 0;
1036 size_t base = x << 6;
1037 while (howmany < capacity) {
1038 while (w != 0) {
1039 uint64_tcxx . . $ uint64_t# t = w & (~w + 1);
1040 int r = roaring_trailing_zeroescxx . . $ roaring_trailing_zeroes(642c2e9948c4ad2).(w);
1041 buffer[howmany++] = r + base;
1042 if (howmany == capacity) goto end;
1043 w ^= t;
1044 }
1045 x += 1;
1046 if (x == bitset->arraysizecxx . . $ bitset_s#arraysize.) {
1047 break;
1048 }
1049 base += 64;
1050 w = bitset->arraycxx . . $ bitset_s#array.[x];
1051 }
1052 end:
1053 if (howmany > 0) {
1054 *startfrom = buffer[howmany - 1];
1055 }
1056 return howmany;
1057 }
1058
1059 typedef boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! (*bitset_iteratorcxx . . $ bitset_iterator#)(size_t value, void *param);
1060
1061 // return true if uninterrupted
1062 static inline boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! bitset_for_eachcxx . . $ bitset_for_each(869cbcaba8167340).(const bitset_tcxx . . $ bitset_t# *b, bitset_iteratorcxx . . $ bitset_iterator# iterator,
1063 void *ptr) {
1064 size_t base = 0;
1065 for (size_t i = 0; i < b->arraysizecxx . . $ bitset_s#arraysize.; ++i) {
1066 uint64_tcxx . . $ uint64_t# w = b->arraycxx . . $ bitset_s#array.[i];
1067 while (w != 0) {
1068 uint64_tcxx . . $ uint64_t# t = w & (~w + 1);
1069 int r = roaring_trailing_zeroescxx . . $ roaring_trailing_zeroes(642c2e9948c4ad2).(w);
1070 if (!iterator(r + base, ptr)) return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1071 w ^= t;
1072 }
1073 base += 64;
1074 }
1075 return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1076 }
1077
1078 static inline void bitset_printcxx . . $ bitset_print(be999344369a4bbe).(const bitset_tcxx . . $ bitset_t# *b) {
1079 printfcxx . . $ printf(581fddd72a8db8fc).("{");
1080 for (size_t i = 0; bitset_next_set_bitcxx . . $ bitset_next_set_bit(3dd7b76510ed14ff).(b, &i); i++) {
1081 printfcxx . . $ printf(581fddd72a8db8fc).("%zu, ", i);
1082 }
1083 printfcxx . . $ printf(581fddd72a8db8fc).("}");
1084 }
1085
1086 #ifdef __cplusplus
1087 }
1088 }
1089 } // extern "C" { namespace roaring { namespace api {
1090 #endif
1091
1092 #endif
1093 /* end file include/roaring/bitset/bitset.h */
1094 /* begin file include/roaring/roaring.h */
1095 /*
1096 * An implementation of Roaring Bitmaps in C.
1097 */
1098
1099 #ifndef ROARING_Hcxx . . $ `gtk/roaring/roaring.h:1100:9`!
1100 #define ROARING_Hcxx . . $ `gtk/roaring/roaring.h:1100:9`!
1101
1102 #include <stdbool.h>
1103 #include <stddef.h> // for `size_t`
1104 #include <stdint.h>
1105
1106
1107 // Include other headers after roaring_types.h
1108
1109 #ifdef __cplusplus
1110 extern "C" {
1111 namespace roaring {
1112 namespace api {
1113 #endif
1114
1115 typedef struct roaring_bitmap_scxx . . $ roaring_bitmap_s# {
1116 roaring_array_tcxx . . $ roaring_array_t# high_low_containercxx . . $ roaring_bitmap_s#high_low_container.;
1117 } roaring_bitmap_tcxx . . $ roaring_bitmap_t#;
1118
1119 /**
1120 * Dynamically allocates a new bitmap (initially empty).
1121 * Returns NULL if the allocation fails.
1122 * Capacity is a performance hint for how many "containers" the data will need.
1123 * Client is responsible for calling `roaring_bitmap_free()`.
1124 */
1125 static roaring_bitmap_tcxx . . $ roaring_bitmap_t# *roaring_bitmap_create_with_capacitycxx . . $ roaring_bitmap_create_with_capacity(3b736f2496b443c7).(uint32_tcxx . . $ uint32_t# cap);
1126
1127 /**
1128 * Dynamically allocates a new bitmap (initially empty).
1129 * Returns NULL if the allocation fails.
1130 * Client is responsible for calling `roaring_bitmap_free()`.
1131 */
1132 static inline roaring_bitmap_tcxx . . $ roaring_bitmap_t# *roaring_bitmap_createcxx . . $ roaring_bitmap_create(a4ddb25c6350e493).(void) {
1133 return roaring_bitmap_create_with_capacitycxx . . $ roaring_bitmap_create_with_capacity(3b736f2496b443c7).(0);
1134 }
1135
1136 /**
1137 * Initialize a roaring bitmap structure in memory controlled by client.
1138 * Capacity is a performance hint for how many "containers" the data will need.
1139 * Can return false if auxiliary allocations fail when capacity greater than 0.
1140 */
1141 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring_bitmap_init_with_capacitycxx . . $ roaring_bitmap_init_with_capacity(480d1da0141ce60a).(roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r, uint32_tcxx . . $ uint32_t# cap);
1142
1143 /**
1144 * Initialize a roaring bitmap structure in memory controlled by client.
1145 * The bitmap will be in a "clear" state, with no auxiliary allocations.
1146 * Since this performs no allocations, the function will not fail.
1147 */
1148 static inline void roaring_bitmap_init_clearedcxx . . $ roaring_bitmap_init_cleared(1264bb6bea08f0c1).(roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r) {
1149 roaring_bitmap_init_with_capacitycxx . . $ roaring_bitmap_init_with_capacity(480d1da0141ce60a).(r, 0);
1150 }
1151
1152 /**
1153 * Add all the values between min (included) and max (excluded) that are at a
1154 * distance k*step from min.
1155 * The returned pointer may be NULL in case of errors.
1156 */
1157 static roaring_bitmap_tcxx . . $ roaring_bitmap_t# *roaring_bitmap_from_rangecxx . . $ roaring_bitmap_from_range(77c15191e3765664).(uint64_tcxx . . $ uint64_t# min, uint64_tcxx . . $ uint64_t# max,
1158 uint32_tcxx . . $ uint32_t# step);
1159
1160 /**
1161 * Creates a new bitmap from a pointer of uint32_t integers
1162 * The returned pointer may be NULL in case of errors.
1163 */
1164 static roaring_bitmap_tcxx . . $ roaring_bitmap_t# *roaring_bitmap_of_ptrcxx . . $ roaring_bitmap_of_ptr(77057284fcc9c438).(size_t n_args, const uint32_tcxx . . $ uint32_t# *vals);
1165
1166 /*
1167 * Whether you want to use copy-on-write.
1168 * Saves memory and avoids copies, but needs more care in a threaded context.
1169 * Most users should ignore this flag.
1170 *
1171 * Note: If you do turn this flag to 'true', enabling COW, then ensure that you
1172 * do so for all of your bitmaps, since interactions between bitmaps with and
1173 * without COW is unsafe.
1174 */
1175 static inline boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring_bitmap_get_copy_on_writecxx . . $ roaring_bitmap_get_copy_on_write(383682ce4763b98f).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r) {
1176 return r->high_low_containercxx . . $ roaring_bitmap_s#high_low_container..flagscxx . . $ roaring_array_s#flags. & ROARING_FLAG_COWcxx . . $ `gtk/roaring/roaring.h:680:9`!;
1177 }
1178 static inline void roaring_bitmap_set_copy_on_writecxx . . $ roaring_bitmap_set_copy_on_write(10ab9bd0603e4eea).(roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r, boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! cow) {
1179 if (cow) {
1180 r->high_low_containercxx . . $ roaring_bitmap_s#high_low_container..flagscxx . . $ roaring_array_s#flags. |= ROARING_FLAG_COWcxx . . $ `gtk/roaring/roaring.h:680:9`!;
1181 } else {
1182 r->high_low_containercxx . . $ roaring_bitmap_s#high_low_container..flagscxx . . $ roaring_array_s#flags. &= ~ROARING_FLAG_COWcxx . . $ `gtk/roaring/roaring.h:680:9`!;
1183 }
1184 }
1185
1186 /**
1187 * Return a copy of the bitmap with all values shifted by offset.
1188 * The returned pointer may be NULL in case of errors. The caller is responsible
1189 * for freeing the return bitmap.
1190 */
1191 static roaring_bitmap_tcxx . . $ roaring_bitmap_t# *roaring_bitmap_add_offsetcxx . . $ roaring_bitmap_add_offset(8d80f7c873c41cbc).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *bm,
1192 int64_tcxx . . $ int64_t# offset);
1193 /**
1194 * Describe the inner structure of the bitmap.
1195 */
1196 static void roaring_bitmap_printf_describecxx . . $ roaring_bitmap_printf_describe(37cb524632c5288f).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r);
1197
1198 /**
1199 * Creates a new bitmap from a list of uint32_t integers
1200 *
1201 * This function is deprecated, use `roaring_bitmap_from` instead, which
1202 * doesn't require the number of elements to be passed in.
1203 *
1204 * @see roaring_bitmap_from
1205 */
1206 CROARING_DEPRECATEDcxx . . $ `gtk/roaring/roaring.h:609:9`! static roaring_bitmap_tcxx . . $ roaring_bitmap_t# *roaring_bitmap_ofcxx . . $ roaring_bitmap_of(80d6f4423a6c7e63).(size_t n, ...);
1207
1208 #ifdef __cplusplus
1209 /**
1210 * Creates a new bitmap which contains all values passed in as arguments.
1211 *
1212 * To create a bitmap from a variable number of arguments, use the
1213 * `roaring_bitmap_of_ptr` function instead.
1214 */
1215 // Use an immediately invoked closure, capturing by reference
1216 // (in case __VA_ARGS__ refers to context outside the closure)
1217 // Include a 0 at the beginning of the array to make the array length > 0
1218 // (zero sized arrays are not valid in standard c/c++)
1219 #define roaring_bitmap_from(...) \
1220 [&]() { \
1221 const uint32_t roaring_bitmap_from_array[] = {0, __VA_ARGS__}; \
1222 return roaring_bitmap_of_ptr((sizeof(roaring_bitmap_from_array) / \
1223 sizeof(roaring_bitmap_from_array[0])) - \
1224 1, \
1225 &roaring_bitmap_from_array[1]); \
1226 }()
1227 #else
1228 /**
1229 * Creates a new bitmap which contains all values passed in as arguments.
1230 *
1231 * To create a bitmap from a variable number of arguments, use the
1232 * `roaring_bitmap_of_ptr` function instead.
1233 */
1234 // While __VA_ARGS__ occurs twice in expansion, one of the times is in a sizeof
1235 // expression, which is an unevaluated context, so it's even safe in the case
1236 // where expressions passed have side effects (roaring64_bitmap_from(my_func(),
1237 // ++i))
1238 // Include a 0 at the beginning of the array to make the array length > 0
1239 // (zero sized arrays are not valid in standard c/c++)
1240 #define roaring_bitmap_fromcxx . . $ `gtk/roaring/roaring.h:1240:9`!(...) \
1241 roaring_bitmap_of_ptr( \
1242 (sizeof((const uint32_t[]){0, __VA_ARGS__}) / sizeof(uint32_t)) - 1, \
1243 &((const uint32_t[]){0, __VA_ARGS__})[1])
1244 #endif
1245
1246 /**
1247 * Copies a bitmap (this does memory allocation).
1248 * The caller is responsible for memory management.
1249 * The returned pointer may be NULL in case of errors.
1250 */
1251 static roaring_bitmap_tcxx . . $ roaring_bitmap_t# *roaring_bitmap_copycxx . . $ roaring_bitmap_copy(d78e3fdf5cf58efc).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r);
1252
1253 /**
1254 * Copies a bitmap from src to dest. It is assumed that the pointer dest
1255 * is to an already allocated bitmap. The content of the dest bitmap is
1256 * freed/deleted.
1257 *
1258 * It might be preferable and simpler to call roaring_bitmap_copy except
1259 * that roaring_bitmap_overwrite can save on memory allocations.
1260 *
1261 * Returns true if successful, or false if there was an error. On failure,
1262 * the dest bitmap is left in a valid, empty state (even if it was not empty
1263 * before).
1264 */
1265 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring_bitmap_overwritecxx . . $ roaring_bitmap_overwrite(1ac3cae7fc30611).(roaring_bitmap_tcxx . . $ roaring_bitmap_t# *dest,
1266 const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *src);
1267
1268 /**
1269 * Print the content of the bitmap.
1270 */
1271 static void roaring_bitmap_printfcxx . . $ roaring_bitmap_printf(37cb524632c5288f).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r);
1272
1273 /**
1274 * Computes the intersection between two bitmaps and returns new bitmap. The
1275 * caller is responsible for memory management.
1276 *
1277 * Performance hint: if you are computing the intersection between several
1278 * bitmaps, two-by-two, it is best to start with the smallest bitmap.
1279 * You may also rely on roaring_bitmap_and_inplace to avoid creating
1280 * many temporary bitmaps.
1281 * The returned pointer may be NULL in case of errors.
1282 */
1283 static roaring_bitmap_tcxx . . $ roaring_bitmap_t# *roaring_bitmap_andcxx . . $ roaring_bitmap_and(f8bdab3e3544b161).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r1,
1284 const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r2);
1285
1286 /**
1287 * Computes the size of the intersection between two bitmaps.
1288 */
1289 static uint64_tcxx . . $ uint64_t# roaring_bitmap_and_cardinalitycxx . . $ roaring_bitmap_and_cardinality(26d1f035fdba821e).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r1,
1290 const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r2);
1291
1292 /**
1293 * Check whether two bitmaps intersect.
1294 */
1295 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring_bitmap_intersectcxx . . $ roaring_bitmap_intersect(29ff8763cd1fb4c1).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r1,
1296 const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r2);
1297
1298 /**
1299 * Check whether a bitmap and an open range intersect.
1300 */
1301 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring_bitmap_intersect_with_rangecxx . . $ roaring_bitmap_intersect_with_range(978cd87c99edbf9e).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *bm, uint64_tcxx . . $ uint64_t# x,
1302 uint64_tcxx . . $ uint64_t# y);
1303
1304 /**
1305 * Computes the Jaccard index between two bitmaps. (Also known as the Tanimoto
1306 * distance, or the Jaccard similarity coefficient)
1307 *
1308 * The Jaccard index is undefined if both bitmaps are empty.
1309 */
1310 static double roaring_bitmap_jaccard_indexcxx . . $ roaring_bitmap_jaccard_index(36b9288fe36e04ca).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r1,
1311 const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r2);
1312
1313 /**
1314 * Computes the size of the union between two bitmaps.
1315 */
1316 static uint64_tcxx . . $ uint64_t# roaring_bitmap_or_cardinalitycxx . . $ roaring_bitmap_or_cardinality(26d1f035fdba821e).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r1,
1317 const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r2);
1318
1319 /**
1320 * Computes the size of the difference (andnot) between two bitmaps.
1321 */
1322 static uint64_tcxx . . $ uint64_t# roaring_bitmap_andnot_cardinalitycxx . . $ roaring_bitmap_andnot_cardinality(26d1f035fdba821e).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r1,
1323 const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r2);
1324
1325 /**
1326 * Computes the size of the symmetric difference (xor) between two bitmaps.
1327 */
1328 static uint64_tcxx . . $ uint64_t# roaring_bitmap_xor_cardinalitycxx . . $ roaring_bitmap_xor_cardinality(26d1f035fdba821e).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r1,
1329 const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r2);
1330
1331 /**
1332 * Inplace version of `roaring_bitmap_and()`, modifies r1
1333 * r1 == r2 is allowed.
1334 *
1335 * Performance hint: if you are computing the intersection between several
1336 * bitmaps, two-by-two, it is best to start with the smallest bitmap.
1337 */
1338 static void roaring_bitmap_and_inplacecxx . . $ roaring_bitmap_and_inplace(ba279031f857c4e1).(roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r1,
1339 const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r2);
1340
1341 /**
1342 * Computes the union between two bitmaps and returns new bitmap. The caller is
1343 * responsible for memory management.
1344 * The returned pointer may be NULL in case of errors.
1345 */
1346 static roaring_bitmap_tcxx . . $ roaring_bitmap_t# *roaring_bitmap_orcxx . . $ roaring_bitmap_or(f8bdab3e3544b161).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r1,
1347 const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r2);
1348
1349 /**
1350 * Inplace version of `roaring_bitmap_or(), modifies r1.
1351 * TODO: decide whether r1 == r2 ok
1352 */
1353 static void roaring_bitmap_or_inplacecxx . . $ roaring_bitmap_or_inplace(ba279031f857c4e1).(roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r1,
1354 const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r2);
1355
1356 /**
1357 * Compute the union of 'number' bitmaps.
1358 * Caller is responsible for freeing the result.
1359 * See also `roaring_bitmap_or_many_heap()`
1360 * The returned pointer may be NULL in case of errors.
1361 */
1362 static roaring_bitmap_tcxx . . $ roaring_bitmap_t# *roaring_bitmap_or_manycxx . . $ roaring_bitmap_or_many(19dd8d5a8535d148).(size_t number,
1363 const roaring_bitmap_tcxx . . $ roaring_bitmap_t# **rs);
1364
1365 /**
1366 * Compute the union of 'number' bitmaps using a heap. This can sometimes be
1367 * faster than `roaring_bitmap_or_many() which uses a naive algorithm.
1368 * Caller is responsible for freeing the result.
1369 */
1370 static roaring_bitmap_tcxx . . $ roaring_bitmap_t# *roaring_bitmap_or_many_heapcxx . . $ roaring_bitmap_or_many_heap(956513401d5f1129).(uint32_tcxx . . $ uint32_t# number,
1371 const roaring_bitmap_tcxx . . $ roaring_bitmap_t# **rs);
1372
1373 /**
1374 * Computes the symmetric difference (xor) between two bitmaps
1375 * and returns new bitmap. The caller is responsible for memory management.
1376 * The returned pointer may be NULL in case of errors.
1377 */
1378 static roaring_bitmap_tcxx . . $ roaring_bitmap_t# *roaring_bitmap_xorcxx . . $ roaring_bitmap_xor(f8bdab3e3544b161).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r1,
1379 const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r2);
1380
1381 /**
1382 * Inplace version of roaring_bitmap_xor, modifies r1, r1 != r2.
1383 */
1384 static void roaring_bitmap_xor_inplacecxx . . $ roaring_bitmap_xor_inplace(ba279031f857c4e1).(roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r1,
1385 const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r2);
1386
1387 /**
1388 * Compute the xor of 'number' bitmaps.
1389 * Caller is responsible for freeing the result.
1390 * The returned pointer may be NULL in case of errors.
1391 */
1392 static roaring_bitmap_tcxx . . $ roaring_bitmap_t# *roaring_bitmap_xor_manycxx . . $ roaring_bitmap_xor_many(19dd8d5a8535d148).(size_t number,
1393 const roaring_bitmap_tcxx . . $ roaring_bitmap_t# **rs);
1394
1395 /**
1396 * Computes the difference (andnot) between two bitmaps and returns new bitmap.
1397 * Caller is responsible for freeing the result.
1398 * The returned pointer may be NULL in case of errors.
1399 */
1400 static roaring_bitmap_tcxx . . $ roaring_bitmap_t# *roaring_bitmap_andnotcxx . . $ roaring_bitmap_andnot(f8bdab3e3544b161).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r1,
1401 const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r2);
1402
1403 /**
1404 * Inplace version of roaring_bitmap_andnot, modifies r1, r1 != r2.
1405 */
1406 static void roaring_bitmap_andnot_inplacecxx . . $ roaring_bitmap_andnot_inplace(ba279031f857c4e1).(roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r1,
1407 const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r2);
1408
1409 /**
1410 * TODO: consider implementing:
1411 *
1412 * "Compute the xor of 'number' bitmaps using a heap. This can sometimes be
1413 * faster than roaring_bitmap_xor_many which uses a naive algorithm. Caller is
1414 * responsible for freeing the result.""
1415 *
1416 * roaring_bitmap_t *roaring_bitmap_xor_many_heap(uint32_t number,
1417 * const roaring_bitmap_t **rs);
1418 */
1419
1420 /**
1421 * Frees the memory.
1422 */
1423 static void roaring_bitmap_freecxx . . $ roaring_bitmap_free(37cb524632c5288f).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r);
1424
1425 /**
1426 * A bit of context usable with `roaring_bitmap_*_bulk()` functions
1427 *
1428 * Should be initialized with `{0}` (or `memset()` to all zeros).
1429 * Callers should treat it as an opaque type.
1430 *
1431 * A context may only be used with a single bitmap
1432 * (unless re-initialized to zero), and any modification to a bitmap
1433 * (other than modifications performed with `_bulk()` functions with the context
1434 * passed) will invalidate any contexts associated with that bitmap.
1435 */
1436 typedef struct roaring_bulk_context_scxx . . $ roaring_bulk_context_s# {
1437 ROARING_CONTAINER_Tcxx . . $ `gtk/roaring/roaring.h:677:9`! *containercxx . . $ roaring_bulk_context_s#container.;
1438 int idxcxx . . $ roaring_bulk_context_s#idx.;
1439 uint16_tcxx . . $ uint16_t# keycxx . . $ roaring_bulk_context_s#key.;
1440 uint8_tcxx . . $ uint8_t# typecodecxx . . $ roaring_bulk_context_s#typecode.;
1441 } roaring_bulk_context_tcxx . . $ roaring_bulk_context_t#;
1442
1443 /**
1444 * Add an item, using context from a previous insert for speed optimization.
1445 *
1446 * `context` will be used to store information between calls to make bulk
1447 * operations faster. `*context` should be zero-initialized before the first
1448 * call to this function.
1449 *
1450 * Modifying the bitmap in any way (other than `-bulk` suffixed functions)
1451 * will invalidate the stored context, calling this function with a non-zero
1452 * context after doing any modification invokes undefined behavior.
1453 *
1454 * In order to exploit this optimization, the caller should call this function
1455 * with values with the same "key" (high 16 bits of the value) consecutively.
1456 */
1457 static void roaring_bitmap_add_bulkcxx . . $ roaring_bitmap_add_bulk(a85b90b04defed40).(roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r,
1458 roaring_bulk_context_tcxx . . $ roaring_bulk_context_t# *context, uint32_tcxx . . $ uint32_t# val);
1459
1460 /**
1461 * Add value n_args from pointer vals, faster than repeatedly calling
1462 * `roaring_bitmap_add()`
1463 *
1464 * In order to exploit this optimization, the caller should attempt to keep
1465 * values with the same "key" (high 16 bits of the value) as consecutive
1466 * elements in `vals`
1467 */
1468 static void roaring_bitmap_add_manycxx . . $ roaring_bitmap_add_many(bdc8247bd025b6ba).(roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r, size_t n_args,
1469 const uint32_tcxx . . $ uint32_t# *vals);
1470
1471 /**
1472 * Add value x
1473 */
1474 static void roaring_bitmap_addcxx . . $ roaring_bitmap_add(b1681775d06b182a).(roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r, uint32_tcxx . . $ uint32_t# x);
1475
1476 /**
1477 * Add value x
1478 * Returns true if a new value was added, false if the value already existed.
1479 */
1480 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring_bitmap_add_checkedcxx . . $ roaring_bitmap_add_checked(480d1da0141ce60a).(roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r, uint32_tcxx . . $ uint32_t# x);
1481
1482 /**
1483 * Add all values in range [min, max]
1484 */
1485 static void roaring_bitmap_add_range_closedcxx . . $ roaring_bitmap_add_range_closed(b93b8642e2562fce).(roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r, uint32_tcxx . . $ uint32_t# min,
1486 uint32_tcxx . . $ uint32_t# max);
1487
1488 /**
1489 * Add all values in range [min, max)
1490 */
1491 static inline void roaring_bitmap_add_rangecxx . . $ roaring_bitmap_add_range(6171755b64b099ec).(roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r, uint64_tcxx . . $ uint64_t# min,
1492 uint64_tcxx . . $ uint64_t# max) {
1493 if (max <= min || min > (uint64_tcxx . . $ uint64_t#)UINT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:118:10`! + 1) {
1494 return;
1495 }
1496 roaring_bitmap_add_range_closedcxx . . $ roaring_bitmap_add_range_closed(b93b8642e2562fce).(r, (uint32_tcxx . . $ uint32_t#)min, (uint32_tcxx . . $ uint32_t#)(max - 1));
1497 }
1498
1499 /**
1500 * Remove value x
1501 */
1502 static void roaring_bitmap_removecxx . . $ roaring_bitmap_remove(b1681775d06b182a).(roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r, uint32_tcxx . . $ uint32_t# x);
1503
1504 /**
1505 * Remove all values in range [min, max]
1506 */
1507 static void roaring_bitmap_remove_range_closedcxx . . $ roaring_bitmap_remove_range_closed(b93b8642e2562fce).(roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r, uint32_tcxx . . $ uint32_t# min,
1508 uint32_tcxx . . $ uint32_t# max);
1509
1510 /**
1511 * Remove all values in range [min, max)
1512 */
1513 static inline void roaring_bitmap_remove_rangecxx . . $ roaring_bitmap_remove_range(6171755b64b099ec).(roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r, uint64_tcxx . . $ uint64_t# min,
1514 uint64_tcxx . . $ uint64_t# max) {
1515 if (max <= min || min > (uint64_tcxx . . $ uint64_t#)UINT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:118:10`! + 1) {
1516 return;
1517 }
1518 roaring_bitmap_remove_range_closedcxx . . $ roaring_bitmap_remove_range_closed(b93b8642e2562fce).(r, (uint32_tcxx . . $ uint32_t#)min, (uint32_tcxx . . $ uint32_t#)(max - 1));
1519 }
1520
1521 /**
1522 * Remove multiple values
1523 */
1524 static void roaring_bitmap_remove_manycxx . . $ roaring_bitmap_remove_many(bdc8247bd025b6ba).(roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r, size_t n_args,
1525 const uint32_tcxx . . $ uint32_t# *vals);
1526
1527 /**
1528 * Remove value x
1529 * Returns true if a new value was removed, false if the value was not existing.
1530 */
1531 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring_bitmap_remove_checkedcxx . . $ roaring_bitmap_remove_checked(480d1da0141ce60a).(roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r, uint32_tcxx . . $ uint32_t# x);
1532
1533 /**
1534 * Check if value is present
1535 */
1536 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring_bitmap_containscxx . . $ roaring_bitmap_contains(273f4841d5a12761).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r, uint32_tcxx . . $ uint32_t# val);
1537
1538 /**
1539 * Check whether a range of values from range_start (included)
1540 * to range_end (excluded) is present
1541 */
1542 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring_bitmap_contains_rangecxx . . $ roaring_bitmap_contains_range(978cd87c99edbf9e).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r,
1543 uint64_tcxx . . $ uint64_t# range_start, uint64_tcxx . . $ uint64_t# range_end);
1544
1545 /**
1546 * Check whether a range of values from range_start (included)
1547 * to range_end (included) is present
1548 */
1549 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring_bitmap_contains_range_closedcxx . . $ roaring_bitmap_contains_range_closed(f813147680abe82a).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r,
1550 uint32_tcxx . . $ uint32_t# range_start,
1551 uint32_tcxx . . $ uint32_t# range_end);
1552
1553 /**
1554 * Check if an items is present, using context from a previous insert or search
1555 * for speed optimization.
1556 *
1557 * `context` will be used to store information between calls to make bulk
1558 * operations faster. `*context` should be zero-initialized before the first
1559 * call to this function.
1560 *
1561 * Modifying the bitmap in any way (other than `-bulk` suffixed functions)
1562 * will invalidate the stored context, calling this function with a non-zero
1563 * context after doing any modification invokes undefined behavior.
1564 *
1565 * In order to exploit this optimization, the caller should call this function
1566 * with values with the same "key" (high 16 bits of the value) consecutively.
1567 */
1568 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring_bitmap_contains_bulkcxx . . $ roaring_bitmap_contains_bulk(ef77f85a7da2066b).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r,
1569 roaring_bulk_context_tcxx . . $ roaring_bulk_context_t# *context,
1570 uint32_tcxx . . $ uint32_t# val);
1571
1572 /**
1573 * Get the cardinality of the bitmap (number of elements).
1574 */
1575 static uint64_tcxx . . $ uint64_t# roaring_bitmap_get_cardinalitycxx . . $ roaring_bitmap_get_cardinality(65a1454263bc64b9).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r);
1576
1577 /**
1578 * Returns the number of elements in the range [range_start, range_end).
1579 */
1580 static uint64_tcxx . . $ uint64_t# roaring_bitmap_range_cardinalitycxx . . $ roaring_bitmap_range_cardinality(c2c12e76cded5a31).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r,
1581 uint64_tcxx . . $ uint64_t# range_start,
1582 uint64_tcxx . . $ uint64_t# range_end);
1583
1584 /**
1585 * Returns the number of elements in the range [range_start, range_end].
1586 */
1587 static uint64_tcxx . . $ uint64_t# roaring_bitmap_range_cardinality_closedcxx . . $ roaring_bitmap_range_cardinality_closed(4a9fb584e56b9fc7).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r,
1588 uint32_tcxx . . $ uint32_t# range_start,
1589 uint32_tcxx . . $ uint32_t# range_end);
1590 /**
1591 * Returns true if the bitmap is empty (cardinality is zero).
1592 */
1593 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring_bitmap_is_emptycxx . . $ roaring_bitmap_is_empty(383682ce4763b98f).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r);
1594
1595 /**
1596 * Empties the bitmap. It will have no auxiliary allocations (so if the bitmap
1597 * was initialized in client memory via roaring_bitmap_init(), then a call to
1598 * roaring_bitmap_clear() would be enough to "free" it)
1599 */
1600 static void roaring_bitmap_clearcxx . . $ roaring_bitmap_clear(1264bb6bea08f0c1).(roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r);
1601
1602 /**
1603 * Convert the bitmap to a sorted array, output in `ans`.
1604 *
1605 * Caller is responsible to ensure that there is enough memory allocated, e.g.
1606 *
1607 * ans = malloc(roaring_bitmap_get_cardinality(bitmap) * sizeof(uint32_t));
1608 */
1609 static void roaring_bitmap_to_uint32_arraycxx . . $ roaring_bitmap_to_uint32_array(f6f54e1b3bd85cc2).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r, uint32_tcxx . . $ uint32_t# *ans);
1610
1611 /**
1612 * Store the bitmap to a bitset. This can be useful for people
1613 * who need the performance and simplicity of a standard bitset.
1614 * We assume that the input bitset is originally empty (does not
1615 * have any set bit).
1616 *
1617 * bitset_t * out = bitset_create();
1618 * // if the bitset has content in it, call "bitset_clear(out)"
1619 * bool success = roaring_bitmap_to_bitset(mybitmap, out);
1620 * // on failure, success will be false.
1621 * // You can then query the bitset:
1622 * bool is_present = bitset_get(out, 10011 );
1623 * // you must free the memory:
1624 * bitset_free(out);
1625 *
1626 */
1627 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring_bitmap_to_bitsetcxx . . $ roaring_bitmap_to_bitset(12e326cd5118829a).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r, bitset_tcxx . . $ bitset_t# *bitset);
1628
1629 /**
1630 * Convert the bitmap to a sorted array from `offset` by `limit`, output in
1631 * `ans`.
1632 *
1633 * Caller is responsible to ensure that there is enough memory allocated, e.g.
1634 *
1635 * ans = malloc(roaring_bitmap_get_cardinality(limit) * sizeof(uint32_t));
1636 *
1637 * Return false in case of failure (e.g., insufficient memory)
1638 */
1639 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring_bitmap_range_uint32_arraycxx . . $ roaring_bitmap_range_uint32_array(23748e9c54efb363).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r, size_t offset,
1640 size_t limit, uint32_tcxx . . $ uint32_t# *ans);
1641
1642 /**
1643 * Remove run-length encoding even when it is more space efficient.
1644 * Return whether a change was applied.
1645 */
1646 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring_bitmap_remove_run_compressioncxx . . $ roaring_bitmap_remove_run_compression(7e17b0a5593a0062).(roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r);
1647
1648 /**
1649 * Convert array and bitmap containers to run containers when it is more
1650 * efficient; also convert from run containers when more space efficient.
1651 *
1652 * Returns true if the result has at least one run container.
1653 * Additional savings might be possible by calling `shrinkToFit()`.
1654 */
1655 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring_bitmap_run_optimizecxx . . $ roaring_bitmap_run_optimize(7e17b0a5593a0062).(roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r);
1656
1657 /**
1658 * If needed, reallocate memory to shrink the memory usage.
1659 * Returns the number of bytes saved.
1660 */
1661 static size_t roaring_bitmap_shrink_to_fitcxx . . $ roaring_bitmap_shrink_to_fit(7aa64495a96639a4).(roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r);
1662
1663 /**
1664 * Write the bitmap to an output pointer, this output buffer should refer to
1665 * at least `roaring_bitmap_size_in_bytes(r)` allocated bytes.
1666 *
1667 * See `roaring_bitmap_portable_serialize()` if you want a format that's
1668 * compatible with Java and Go implementations. This format can sometimes be
1669 * more space efficient than the portable form, e.g. when the data is sparse.
1670 *
1671 * Returns how many bytes written, should be `roaring_bitmap_size_in_bytes(r)`.
1672 *
1673 * This function is endian-sensitive. If you have a big-endian system (e.g., a
1674 * mainframe IBM s390x), the data format is going to be big-endian and not
1675 * compatible with little-endian systems.
1676 *
1677 * When serializing data to a file, we recommend that you also use
1678 * checksums so that, at deserialization, you can be confident
1679 * that you are recovering the correct data.
1680 */
1681 static size_t roaring_bitmap_serializecxx . . $ roaring_bitmap_serialize(49fa165c55ade84d).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r, char *buf);
1682
1683 /**
1684 * Use with `roaring_bitmap_serialize()`.
1685 *
1686 * (See `roaring_bitmap_portable_deserialize()` if you want a format that's
1687 * compatible with Java and Go implementations).
1688 *
1689 * This function is endian-sensitive. If you have a big-endian system (e.g., a
1690 * mainframe IBM s390x), the data format is going to be big-endian and not
1691 * compatible with little-endian systems.
1692 *
1693 * The returned pointer may be NULL in case of errors.
1694 */
1695 static roaring_bitmap_tcxx . . $ roaring_bitmap_t# *roaring_bitmap_deserializecxx . . $ roaring_bitmap_deserialize(82b3d604d9bc11b5).(const void *buf);
1696
1697 /**
1698 * Use with `roaring_bitmap_serialize()`.
1699 *
1700 * (See `roaring_bitmap_portable_deserialize_safe()` if you want a format that's
1701 * compatible with Java and Go implementations).
1702 *
1703 * This function is endian-sensitive. If you have a big-endian system (e.g., a
1704 * mainframe IBM s390x), the data format is going to be big-endian and not
1705 * compatible with little-endian systems.
1706 *
1707 * The difference with `roaring_bitmap_deserialize()` is that this function
1708 * checks that the input buffer is a valid bitmap. If the buffer is too small,
1709 * NULL is returned.
1710 *
1711 * The returned pointer may be NULL in case of errors.
1712 */
1713 static roaring_bitmap_tcxx . . $ roaring_bitmap_t# *roaring_bitmap_deserialize_safecxx . . $ roaring_bitmap_deserialize_safe(75990fc2b8e1b3d7).(const void *buf,
1714 size_t maxbytes);
1715
1716 /**
1717 * How many bytes are required to serialize this bitmap (NOT compatible
1718 * with Java and Go versions)
1719 */
1720 static size_t roaring_bitmap_size_in_bytescxx . . $ roaring_bitmap_size_in_bytes(65a1454263bc64b9).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r);
1721
1722 /**
1723 * Read bitmap from a serialized buffer.
1724 * In case of failure, NULL is returned.
1725 *
1726 * This function is unsafe in the sense that if there is no valid serialized
1727 * bitmap at the pointer, then many bytes could be read, possibly causing a
1728 * buffer overflow. See also roaring_bitmap_portable_deserialize_safe().
1729 *
1730 * This is meant to be compatible with the Java and Go versions:
1731 * https://github.com/RoaringBitmap/RoaringFormatSpec
1732 *
1733 * This function is endian-sensitive. If you have a big-endian system (e.g., a
1734 * mainframe IBM s390x), the data format is going to be big-endian and not
1735 * compatible with little-endian systems.
1736 *
1737 * The returned pointer may be NULL in case of errors.
1738 */
1739 static roaring_bitmap_tcxx . . $ roaring_bitmap_t# *roaring_bitmap_portable_deserializecxx . . $ roaring_bitmap_portable_deserialize(70a10dfda81e57fc).(const char *buf);
1740
1741 /**
1742 * Read bitmap from a serialized buffer safely (reading up to maxbytes).
1743 * In case of failure, NULL is returned.
1744 *
1745 * This is meant to be compatible with the Java and Go versions:
1746 * https://github.com/RoaringBitmap/RoaringFormatSpec
1747 *
1748 * The function itself is safe in the sense that it will not cause buffer
1749 * overflows: it will not read beyond the scope of the provided buffer
1750 * (buf,maxbytes).
1751 *
1752 * However, for correct operations, it is assumed that the bitmap
1753 * read was once serialized from a valid bitmap (i.e., it follows the format
1754 * specification). If you provided an incorrect input (garbage), then the bitmap
1755 * read may not be in a valid state and following operations may not lead to
1756 * sensible results. In particular, the serialized array containers need to be
1757 * in sorted order, and the run containers should be in sorted non-overlapping
1758 * order. This is is guaranteed to happen when serializing an existing bitmap,
1759 * but not for random inputs.
1760 *
1761 * If the source is untrusted, you should call
1762 * roaring_bitmap_internal_validate to check the validity of the
1763 * bitmap prior to using it. Only after calling roaring_bitmap_internal_validate
1764 * is the bitmap considered safe for use.
1765 *
1766 * We also recommend that you use checksums to check that serialized data
1767 * corresponds to the serialized bitmap. The CRoaring library does not provide
1768 * checksumming.
1769 *
1770 * This function is endian-sensitive. If you have a big-endian system (e.g., a
1771 * mainframe IBM s390x), the data format is going to be big-endian and not
1772 * compatible with little-endian systems.
1773 *
1774 * The returned pointer may be NULL in case of errors.
1775 */
1776 static roaring_bitmap_tcxx . . $ roaring_bitmap_t# *roaring_bitmap_portable_deserialize_safecxx . . $ roaring_bitmap_portable_deserialize_safe(60555b3ea2beebbe).(const char *buf,
1777 size_t maxbytes);
1778
1779 /**
1780 * Read bitmap from a serialized buffer.
1781 * In case of failure, NULL is returned.
1782 *
1783 * Bitmap returned by this function can be used in all readonly contexts.
1784 * Bitmap must be freed as usual, by calling roaring_bitmap_free().
1785 * Underlying buffer must not be freed or modified while it backs any bitmaps.
1786 *
1787 * The function is unsafe in the following ways:
1788 * 1) It may execute unaligned memory accesses.
1789 * 2) A buffer overflow may occur if buf does not point to a valid serialized
1790 * bitmap.
1791 *
1792 * This is meant to be compatible with the Java and Go versions:
1793 * https://github.com/RoaringBitmap/RoaringFormatSpec
1794 *
1795 * This function is endian-sensitive. If you have a big-endian system (e.g., a
1796 * mainframe IBM s390x), the data format is going to be big-endian and not
1797 * compatible with little-endian systems.
1798 *
1799 * The returned pointer may be NULL in case of errors.
1800 */
1801 static roaring_bitmap_tcxx . . $ roaring_bitmap_t# *roaring_bitmap_portable_deserialize_frozencxx . . $ roaring_bitmap_portable_deserialize_frozen(70a10dfda81e57fc).(const char *buf);
1802
1803 /**
1804 * Check how many bytes would be read (up to maxbytes) at this pointer if there
1805 * is a bitmap, returns zero if there is no valid bitmap.
1806 *
1807 * This is meant to be compatible with the Java and Go versions:
1808 * https://github.com/RoaringBitmap/RoaringFormatSpec
1809 */
1810 static size_t roaring_bitmap_portable_deserialize_sizecxx . . $ roaring_bitmap_portable_deserialize_size(ac5a385650b4bde5).(const char *buf,
1811 size_t maxbytes);
1812
1813 /**
1814 * How many bytes are required to serialize this bitmap.
1815 *
1816 * This is meant to be compatible with the Java and Go versions:
1817 * https://github.com/RoaringBitmap/RoaringFormatSpec
1818 */
1819 static size_t roaring_bitmap_portable_size_in_bytescxx . . $ roaring_bitmap_portable_size_in_bytes(65a1454263bc64b9).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r);
1820
1821 /**
1822 * Write a bitmap to a char buffer. The output buffer should refer to at least
1823 * `roaring_bitmap_portable_size_in_bytes(r)` bytes of allocated memory.
1824 *
1825 * Returns how many bytes were written which should match
1826 * `roaring_bitmap_portable_size_in_bytes(r)`.
1827 *
1828 * This is meant to be compatible with the Java and Go versions:
1829 * https://github.com/RoaringBitmap/RoaringFormatSpec
1830 *
1831 * This function is endian-sensitive. If you have a big-endian system (e.g., a
1832 * mainframe IBM s390x), the data format is going to be big-endian and not
1833 * compatible with little-endian systems.
1834 *
1835 * When serializing data to a file, we recommend that you also use
1836 * checksums so that, at deserialization, you can be confident
1837 * that you are recovering the correct data.
1838 */
1839 static size_t roaring_bitmap_portable_serializecxx . . $ roaring_bitmap_portable_serialize(49fa165c55ade84d).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r, char *buf);
1840
1841 /*
1842 * "Frozen" serialization format imitates memory layout of roaring_bitmap_t.
1843 * Deserialized bitmap is a constant view of the underlying buffer.
1844 * This significantly reduces amount of allocations and copying required during
1845 * deserialization.
1846 * It can be used with memory mapped files.
1847 * Example can be found in benchmarks/frozen_benchmark.c
1848 *
1849 * [#####] const roaring_bitmap_t *
1850 * | | |
1851 * +----+ | +-+
1852 * | | |
1853 * [#####################################] underlying buffer
1854 *
1855 * Note that because frozen serialization format imitates C memory layout
1856 * of roaring_bitmap_t, it is not fixed. It is different on big/little endian
1857 * platforms and can be changed in future.
1858 */
1859
1860 /**
1861 * Returns number of bytes required to serialize bitmap using frozen format.
1862 */
1863 static size_t roaring_bitmap_frozen_size_in_bytescxx . . $ roaring_bitmap_frozen_size_in_bytes(65a1454263bc64b9).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r);
1864
1865 /**
1866 * Serializes bitmap using frozen format.
1867 * Buffer size must be at least roaring_bitmap_frozen_size_in_bytes().
1868 *
1869 * This function is endian-sensitive. If you have a big-endian system (e.g., a
1870 * mainframe IBM s390x), the data format is going to be big-endian and not
1871 * compatible with little-endian systems.
1872 *
1873 * When serializing data to a file, we recommend that you also use
1874 * checksums so that, at deserialization, you can be confident
1875 * that you are recovering the correct data.
1876 */
1877 static void roaring_bitmap_frozen_serializecxx . . $ roaring_bitmap_frozen_serialize(bdc00940eaff2c3c).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r, char *buf);
1878
1879 /**
1880 * Creates constant bitmap that is a view of a given buffer.
1881 * Buffer data should have been written by `roaring_bitmap_frozen_serialize()`
1882 * Its beginning must also be aligned by 32 bytes.
1883 * Length must be equal exactly to `roaring_bitmap_frozen_size_in_bytes()`.
1884 * In case of failure, NULL is returned.
1885 *
1886 * Bitmap returned by this function can be used in all readonly contexts.
1887 * Bitmap must be freed as usual, by calling roaring_bitmap_free().
1888 * Underlying buffer must not be freed or modified while it backs any bitmaps.
1889 *
1890 * This function is endian-sensitive. If you have a big-endian system (e.g., a
1891 * mainframe IBM s390x), the data format is going to be big-endian and not
1892 * compatible with little-endian systems.
1893 */
1894 const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *roaring_bitmap_frozen_viewcxx . . $ roaring_bitmap_frozen_view(37f5e5455e04cf51).(const char *buf,
1895 size_t length);
1896
1897 /**
1898 * Iterate over the bitmap elements. The function iterator is called once for
1899 * all the values with ptr (can be NULL) as the second parameter of each call.
1900 *
1901 * `roaring_iterator` is simply a pointer to a function that returns bool
1902 * (true means that the iteration should continue while false means that it
1903 * should stop), and takes (uint32_t,void*) as inputs.
1904 *
1905 * Returns true if the roaring_iterator returned true throughout (so that all
1906 * data points were necessarily visited).
1907 *
1908 * Iteration is ordered: from the smallest to the largest elements.
1909 */
1910 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring_iteratecxx . . $ roaring_iterate(45c1aed37d585a26).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r, roaring_iteratorcxx . . $ roaring_iterator# iterator,
1911 void *ptr);
1912
1913 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring_iterate64cxx . . $ roaring_iterate64(8e2dbe4c6a4518c8).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r, roaring_iterator64cxx . . $ roaring_iterator64# iterator,
1914 uint64_tcxx . . $ uint64_t# high_bits, void *ptr);
1915
1916 /**
1917 * Return true if the two bitmaps contain the same elements.
1918 */
1919 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring_bitmap_equalscxx . . $ roaring_bitmap_equals(29ff8763cd1fb4c1).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r1,
1920 const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r2);
1921
1922 /**
1923 * Return true if all the elements of r1 are also in r2.
1924 */
1925 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring_bitmap_is_subsetcxx . . $ roaring_bitmap_is_subset(29ff8763cd1fb4c1).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r1,
1926 const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r2);
1927
1928 /**
1929 * Return true if all the elements of r1 are also in r2, and r2 is strictly
1930 * greater than r1.
1931 */
1932 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring_bitmap_is_strict_subsetcxx . . $ roaring_bitmap_is_strict_subset(29ff8763cd1fb4c1).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r1,
1933 const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r2);
1934
1935 /**
1936 * (For expert users who seek high performance.)
1937 *
1938 * Computes the union between two bitmaps and returns new bitmap. The caller is
1939 * responsible for memory management.
1940 *
1941 * The lazy version defers some computations such as the maintenance of the
1942 * cardinality counts. Thus you must call `roaring_bitmap_repair_after_lazy()`
1943 * after executing "lazy" computations.
1944 *
1945 * It is safe to repeatedly call roaring_bitmap_lazy_or_inplace on the result.
1946 *
1947 * `bitsetconversion` is a flag which determines whether container-container
1948 * operations force a bitset conversion.
1949 *
1950 * The returned pointer may be NULL in case of errors.
1951 */
1952 static roaring_bitmap_tcxx . . $ roaring_bitmap_t# *roaring_bitmap_lazy_orcxx . . $ roaring_bitmap_lazy_or(607bd5cbda9d1cab).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r1,
1953 const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r2,
1954 const boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! bitsetconversion);
1955
1956 /**
1957 * (For expert users who seek high performance.)
1958 *
1959 * Inplace version of roaring_bitmap_lazy_or, modifies r1.
1960 *
1961 * `bitsetconversion` is a flag which determines whether container-container
1962 * operations force a bitset conversion.
1963 */
1964 static void roaring_bitmap_lazy_or_inplacecxx . . $ roaring_bitmap_lazy_or_inplace(5ba14e510bfe2630).(roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r1,
1965 const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r2,
1966 const boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! bitsetconversion);
1967
1968 /**
1969 * (For expert users who seek high performance.)
1970 *
1971 * Execute maintenance on a bitmap created from `roaring_bitmap_lazy_or()`
1972 * or modified with `roaring_bitmap_lazy_or_inplace()`.
1973 */
1974 static void roaring_bitmap_repair_after_lazycxx . . $ roaring_bitmap_repair_after_lazy(1264bb6bea08f0c1).(roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r1);
1975
1976 /**
1977 * Computes the symmetric difference between two bitmaps and returns new bitmap.
1978 * The caller is responsible for memory management.
1979 *
1980 * The lazy version defers some computations such as the maintenance of the
1981 * cardinality counts. Thus you must call `roaring_bitmap_repair_after_lazy()`
1982 * after executing "lazy" computations.
1983 *
1984 * It is safe to repeatedly call `roaring_bitmap_lazy_xor_inplace()` on
1985 * the result.
1986 *
1987 * The returned pointer may be NULL in case of errors.
1988 */
1989 static roaring_bitmap_tcxx . . $ roaring_bitmap_t# *roaring_bitmap_lazy_xorcxx . . $ roaring_bitmap_lazy_xor(f8bdab3e3544b161).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r1,
1990 const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r2);
1991
1992 /**
1993 * (For expert users who seek high performance.)
1994 *
1995 * Inplace version of roaring_bitmap_lazy_xor, modifies r1. r1 != r2
1996 */
1997 static void roaring_bitmap_lazy_xor_inplacecxx . . $ roaring_bitmap_lazy_xor_inplace(ba279031f857c4e1).(roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r1,
1998 const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r2);
1999
2000 /**
2001 * Compute the negation of the bitmap in the interval [range_start, range_end).
2002 * The number of negated values is range_end - range_start.
2003 * Areas outside the range are passed through unchanged.
2004 * The returned pointer may be NULL in case of errors.
2005 */
2006 static roaring_bitmap_tcxx . . $ roaring_bitmap_t# *roaring_bitmap_flipcxx . . $ roaring_bitmap_flip(26d18e4280837230).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r1,
2007 uint64_tcxx . . $ uint64_t# range_start, uint64_tcxx . . $ uint64_t# range_end);
2008
2009 /**
2010 * Compute the negation of the bitmap in the interval [range_start, range_end].
2011 * The number of negated values is range_end - range_start + 1.
2012 * Areas outside the range are passed through unchanged.
2013 * The returned pointer may be NULL in case of errors.
2014 */
2015 static roaring_bitmap_tcxx . . $ roaring_bitmap_t# *roaring_bitmap_flip_closedcxx . . $ roaring_bitmap_flip_closed(12242488a4cd0dec).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *x1,
2016 uint32_tcxx . . $ uint32_t# range_start,
2017 uint32_tcxx . . $ uint32_t# range_end);
2018 /**
2019 * compute (in place) the negation of the roaring bitmap within a specified
2020 * interval: [range_start, range_end). The number of negated values is
2021 * range_end - range_start.
2022 * Areas outside the range are passed through unchanged.
2023 */
2024 static void roaring_bitmap_flip_inplacecxx . . $ roaring_bitmap_flip_inplace(6171755b64b099ec).(roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r1, uint64_tcxx . . $ uint64_t# range_start,
2025 uint64_tcxx . . $ uint64_t# range_end);
2026
2027 /**
2028 * compute (in place) the negation of the roaring bitmap within a specified
2029 * interval: [range_start, range_end]. The number of negated values is
2030 * range_end - range_start + 1.
2031 * Areas outside the range are passed through unchanged.
2032 */
2033 static void roaring_bitmap_flip_inplace_closedcxx . . $ roaring_bitmap_flip_inplace_closed(b93b8642e2562fce).(roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r1,
2034 uint32_tcxx . . $ uint32_t# range_start,
2035 uint32_tcxx . . $ uint32_t# range_end);
2036
2037 /**
2038 * Selects the element at index 'rank' where the smallest element is at index 0.
2039 * If the size of the roaring bitmap is strictly greater than rank, then this
2040 * function returns true and sets element to the element of given rank.
2041 * Otherwise, it returns false.
2042 */
2043 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring_bitmap_selectcxx . . $ roaring_bitmap_select(f71ba2342348e6c2).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r, uint32_tcxx . . $ uint32_t# rank,
2044 uint32_tcxx . . $ uint32_t# *element);
2045
2046 /**
2047 * roaring_bitmap_rank returns the number of integers that are smaller or equal
2048 * to x. Thus if x is the first element, this function will return 1. If
2049 * x is smaller than the smallest element, this function will return 0.
2050 *
2051 * The indexing convention differs between roaring_bitmap_select and
2052 * roaring_bitmap_rank: roaring_bitmap_select refers to the smallest value
2053 * as having index 0, whereas roaring_bitmap_rank returns 1 when ranking
2054 * the smallest value.
2055 */
2056 static uint64_tcxx . . $ uint64_t# roaring_bitmap_rankcxx . . $ roaring_bitmap_rank(ad43383840a7526e).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r, uint32_tcxx . . $ uint32_t# x);
2057
2058 /**
2059 * roaring_bitmap_rank_many is an `Bulk` version of `roaring_bitmap_rank`
2060 * it puts rank value of each element in `[begin .. end)` to `ans[]`
2061 *
2062 * the values in `[begin .. end)` must be sorted in Ascending order;
2063 * Caller is responsible to ensure that there is enough memory allocated, e.g.
2064 *
2065 * ans = malloc((end-begin) * sizeof(uint64_t));
2066 */
2067 static void roaring_bitmap_rank_manycxx . . $ roaring_bitmap_rank_many(fc096a586e869ca9).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r, const uint32_tcxx . . $ uint32_t# *begin,
2068 const uint32_tcxx . . $ uint32_t# *end, uint64_tcxx . . $ uint64_t# *ans);
2069
2070 /**
2071 * Returns the index of x in the given roaring bitmap.
2072 * If the roaring bitmap doesn't contain x , this function will return -1.
2073 * The difference with rank function is that this function will return -1 when x
2074 * is not the element of roaring bitmap, but the rank function will return a
2075 * non-negative number.
2076 */
2077 static int64_tcxx . . $ int64_t# roaring_bitmap_get_indexcxx . . $ roaring_bitmap_get_index(3711183c9d421657).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r, uint32_tcxx . . $ uint32_t# x);
2078
2079 /**
2080 * Returns the smallest value in the set, or UINT32_MAX if the set is empty.
2081 */
2082 static uint32_tcxx . . $ uint32_t# roaring_bitmap_minimumcxx . . $ roaring_bitmap_minimum(520cee2404b880d7).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r);
2083
2084 /**
2085 * Returns the greatest value in the set, or 0 if the set is empty.
2086 */
2087 static uint32_tcxx . . $ uint32_t# roaring_bitmap_maximumcxx . . $ roaring_bitmap_maximum(520cee2404b880d7).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r);
2088
2089 /**
2090 * (For advanced users.)
2091 *
2092 * Collect statistics about the bitmap, see roaring_types.h for
2093 * a description of roaring_statistics_t
2094 */
2095 static void roaring_bitmap_statisticscxx . . $ roaring_bitmap_statistics(2073b96b89e367ed).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r,
2096 roaring_statistics_tcxx . . $ roaring_statistics_t# *stat);
2097
2098 /**
2099 * Perform internal consistency checks. Returns true if the bitmap is
2100 * consistent. It may be useful to call this after deserializing bitmaps from
2101 * untrusted sources. If roaring_bitmap_internal_validate returns true, then the
2102 * bitmap should be consistent and can be trusted not to cause crashes or memory
2103 * corruption.
2104 *
2105 * Note that some operations intentionally leave bitmaps in an inconsistent
2106 * state temporarily, for example, `roaring_bitmap_lazy_*` functions, until
2107 * `roaring_bitmap_repair_after_lazy` is called.
2108 *
2109 * If reason is non-null, it will be set to a string describing the first
2110 * inconsistency found if any.
2111 */
2112 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring_bitmap_internal_validatecxx . . $ roaring_bitmap_internal_validate(49d45f8178cd3601).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r,
2113 const char **reason);
2114
2115 /*********************
2116 * What follows is code use to iterate through values in a roaring bitmap
2117
2118 static roaring_bitmap_t *r =...
2119 static roaring_uint32_iterator_t i;
2120 static roaring_iterator_create(r, &i);
2121 while(i.has_value) {
2122 printf("value = %d\n", i.current_value);
2123 roaring_uint32_iterator_advance(&i);
2124 }
2125
2126 Obviously, if you modify the underlying bitmap, the iterator
2127 becomes invalid. So don't.
2128 */
2129
2130 /**
2131 * A struct used to keep iterator state. Users should only access
2132 * `current_value` and `has_value`, the rest of the type should be treated as
2133 * opaque.
2134 */
2135 typedef struct roaring_uint32_iterator_scxx . . $ roaring_uint32_iterator_s# {
2136 const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *parentcxx . . $ roaring_uint32_iterator_s#parent.; // Owner
2137 const ROARING_CONTAINER_Tcxx . . $ `gtk/roaring/roaring.h:677:9`! *containercxx . . $ roaring_uint32_iterator_s#container.; // Current container
2138 uint8_tcxx . . $ uint8_t# typecodecxx . . $ roaring_uint32_iterator_s#typecode.; // Typecode of current container
2139 int32_tcxx . . $ int32_t# container_indexcxx . . $ roaring_uint32_iterator_s#container_index.; // Current container index
2140 uint32_tcxx . . $ uint32_t# highbitscxx . . $ roaring_uint32_iterator_s#highbits.; // High 16 bits of the current value
2141 roaring_container_iterator_tcxx . . $ roaring_container_iterator_t# container_itcxx . . $ roaring_uint32_iterator_s#container_it.;
2142
2143 uint32_tcxx . . $ uint32_t# current_valuecxx . . $ roaring_uint32_iterator_s#current_value.;
2144 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! has_valuecxx . . $ roaring_uint32_iterator_s#has_value.;
2145 } roaring_uint32_iterator_tcxx . . $ roaring_uint32_iterator_t#;
2146
2147 /**
2148 * Initialize an iterator object that can be used to iterate through the values.
2149 * If there is a value, then this iterator points to the first value and
2150 * `it->has_value` is true. The value is in `it->current_value`.
2151 */
2152 static void roaring_iterator_initcxx . . $ roaring_iterator_init(c2d2f52097783eff).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r,
2153 roaring_uint32_iterator_tcxx . . $ roaring_uint32_iterator_t# *newit);
2154
2155 /** DEPRECATED, use `roaring_iterator_init`. */
2156 CROARING_DEPRECATEDcxx . . $ `gtk/roaring/roaring.h:609:9`! static inline void roaring_init_iteratorcxx . . $ roaring_init_iterator(c2d2f52097783eff).(
2157 const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r, roaring_uint32_iterator_tcxx . . $ roaring_uint32_iterator_t# *newit) {
2158 roaring_iterator_initcxx . . $ roaring_iterator_init(c2d2f52097783eff).(r, newit);
2159 }
2160
2161 /**
2162 * Initialize an iterator object that can be used to iterate through the values.
2163 * If there is a value, then this iterator points to the last value and
2164 * `it->has_value` is true. The value is in `it->current_value`.
2165 */
2166 static void roaring_iterator_init_lastcxx . . $ roaring_iterator_init_last(c2d2f52097783eff).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r,
2167 roaring_uint32_iterator_tcxx . . $ roaring_uint32_iterator_t# *newit);
2168
2169 /** DEPRECATED, use `roaring_iterator_init_last`. */
2170 CROARING_DEPRECATEDcxx . . $ `gtk/roaring/roaring.h:609:9`! static inline void roaring_init_iterator_lastcxx . . $ roaring_init_iterator_last(c2d2f52097783eff).(
2171 const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r, roaring_uint32_iterator_tcxx . . $ roaring_uint32_iterator_t# *newit) {
2172 roaring_iterator_init_lastcxx . . $ roaring_iterator_init_last(c2d2f52097783eff).(r, newit);
2173 }
2174
2175 /**
2176 * Create an iterator object that can be used to iterate through the values.
2177 * Caller is responsible for calling `roaring_free_iterator()`.
2178 *
2179 * The iterator is initialized (this function calls `roaring_iterator_init()`)
2180 * If there is a value, then this iterator points to the first value and
2181 * `it->has_value` is true. The value is in `it->current_value`.
2182 */
2183 static roaring_uint32_iterator_tcxx . . $ roaring_uint32_iterator_t# *roaring_iterator_createcxx . . $ roaring_iterator_create(809b29961e866072).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r);
2184
2185 /** DEPRECATED, use `roaring_iterator_create`. */
2186 CROARING_DEPRECATEDcxx . . $ `gtk/roaring/roaring.h:609:9`! static inline roaring_uint32_iterator_tcxx . . $ roaring_uint32_iterator_t# *
2187 roaring_create_iteratorcxx . . $ roaring_create_iterator(809b29961e866072).(const roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r) {
2188 return roaring_iterator_createcxx . . $ roaring_iterator_create(809b29961e866072).(r);
2189 }
2190
2191 /**
2192 * Advance the iterator. If there is a new value, then `it->has_value` is true.
2193 * The new value is in `it->current_value`. Values are traversed in increasing
2194 * orders. For convenience, returns `it->has_value`.
2195 *
2196 * Once `it->has_value` is false, `roaring_uint32_iterator_advance` should not
2197 * be called on the iterator again. Calling `roaring_uint32_iterator_previous`
2198 * is allowed.
2199 */
2200 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring_uint32_iterator_advancecxx . . $ roaring_uint32_iterator_advance(3b2dc44192927c7).(roaring_uint32_iterator_tcxx . . $ roaring_uint32_iterator_t# *it);
2201
2202 /** DEPRECATED, use `roaring_uint32_iterator_advance`. */
2203 CROARING_DEPRECATEDcxx . . $ `gtk/roaring/roaring.h:609:9`! static inline boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring_advance_uint32_iteratorcxx . . $ roaring_advance_uint32_iterator(3b2dc44192927c7).(
2204 roaring_uint32_iterator_tcxx . . $ roaring_uint32_iterator_t# *it) {
2205 return roaring_uint32_iterator_advancecxx . . $ roaring_uint32_iterator_advance(3b2dc44192927c7).(it);
2206 }
2207
2208 /**
2209 * Decrement the iterator. If there's a new value, then `it->has_value` is true.
2210 * The new value is in `it->current_value`. Values are traversed in decreasing
2211 * order. For convenience, returns `it->has_value`.
2212 *
2213 * Once `it->has_value` is false, `roaring_uint32_iterator_previous` should not
2214 * be called on the iterator again. Calling `roaring_uint32_iterator_advance` is
2215 * allowed.
2216 */
2217 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring_uint32_iterator_previouscxx . . $ roaring_uint32_iterator_previous(3b2dc44192927c7).(roaring_uint32_iterator_tcxx . . $ roaring_uint32_iterator_t# *it);
2218
2219 /** DEPRECATED, use `roaring_uint32_iterator_previous`. */
2220 CROARING_DEPRECATEDcxx . . $ `gtk/roaring/roaring.h:609:9`! static inline boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring_previous_uint32_iteratorcxx . . $ roaring_previous_uint32_iterator(3b2dc44192927c7).(
2221 roaring_uint32_iterator_tcxx . . $ roaring_uint32_iterator_t# *it) {
2222 return roaring_uint32_iterator_previouscxx . . $ roaring_uint32_iterator_previous(3b2dc44192927c7).(it);
2223 }
2224
2225 /**
2226 * Move the iterator to the first value >= `val`. If there is a such a value,
2227 * then `it->has_value` is true. The new value is in `it->current_value`.
2228 * For convenience, returns `it->has_value`.
2229 */
2230 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring_uint32_iterator_move_equalorlargercxx . . $ roaring_uint32_iterator_move_equalorlarger(b10b206bb6919367).(roaring_uint32_iterator_tcxx . . $ roaring_uint32_iterator_t# *it,
2231 uint32_tcxx . . $ uint32_t# val);
2232
2233 /** DEPRECATED, use `roaring_uint32_iterator_move_equalorlarger`. */
2234 CROARING_DEPRECATEDcxx . . $ `gtk/roaring/roaring.h:609:9`! static inline boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`!
2235 roaring_move_uint32_iterator_equalorlargercxx . . $ roaring_move_uint32_iterator_equalorlarger(b10b206bb6919367).(roaring_uint32_iterator_tcxx . . $ roaring_uint32_iterator_t# *it,
2236 uint32_tcxx . . $ uint32_t# val) {
2237 return roaring_uint32_iterator_move_equalorlargercxx . . $ roaring_uint32_iterator_move_equalorlarger(b10b206bb6919367).(it, val);
2238 }
2239
2240 /**
2241 * Creates a copy of an iterator.
2242 * Caller must free it.
2243 */
2244 static roaring_uint32_iterator_tcxx . . $ roaring_uint32_iterator_t# *roaring_uint32_iterator_copycxx . . $ roaring_uint32_iterator_copy(7610bf912723a93c).(
2245 const roaring_uint32_iterator_tcxx . . $ roaring_uint32_iterator_t# *it);
2246
2247 /** DEPRECATED, use `roaring_uint32_iterator_copy`. */
2248 CROARING_DEPRECATEDcxx . . $ `gtk/roaring/roaring.h:609:9`! static inline roaring_uint32_iterator_tcxx . . $ roaring_uint32_iterator_t# *
2249 roaring_copy_uint32_iteratorcxx . . $ roaring_copy_uint32_iterator(7610bf912723a93c).(const roaring_uint32_iterator_tcxx . . $ roaring_uint32_iterator_t# *it) {
2250 return roaring_uint32_iterator_copycxx . . $ roaring_uint32_iterator_copy(7610bf912723a93c).(it);
2251 }
2252
2253 /**
2254 * Free memory following `roaring_iterator_create()`
2255 */
2256 static void roaring_uint32_iterator_freecxx . . $ roaring_uint32_iterator_free(a4250b678ccd0675).(roaring_uint32_iterator_tcxx . . $ roaring_uint32_iterator_t# *it);
2257
2258 /** DEPRECATED, use `roaring_uint32_iterator_free`. */
2259 CROARING_DEPRECATEDcxx . . $ `gtk/roaring/roaring.h:609:9`! static inline void roaring_free_uint32_iteratorcxx . . $ roaring_free_uint32_iterator(a4250b678ccd0675).(
2260 roaring_uint32_iterator_tcxx . . $ roaring_uint32_iterator_t# *it) {
2261 roaring_uint32_iterator_freecxx . . $ roaring_uint32_iterator_free(a4250b678ccd0675).(it);
2262 }
2263
2264 /*
2265 * Reads next ${count} values from iterator into user-supplied ${buf}.
2266 * Returns the number of read elements.
2267 * This number can be smaller than ${count}, which means that iterator is
2268 * drained.
2269 *
2270 * This function satisfies semantics of iteration and can be used together with
2271 * other iterator functions.
2272 * - first value is copied from ${it}->current_value
2273 * - after function returns, iterator is positioned at the next element
2274 */
2275 static uint32_tcxx . . $ uint32_t# roaring_uint32_iterator_readcxx . . $ roaring_uint32_iterator_read(f43d544532b4da60).(roaring_uint32_iterator_tcxx . . $ roaring_uint32_iterator_t# *it,
2276 uint32_tcxx . . $ uint32_t# *buf, uint32_tcxx . . $ uint32_t# count);
2277
2278 /** DEPRECATED, use `roaring_uint32_iterator_read`. */
2279 CROARING_DEPRECATEDcxx . . $ `gtk/roaring/roaring.h:609:9`! static inline uint32_tcxx . . $ uint32_t# roaring_read_uint32_iteratorcxx . . $ roaring_read_uint32_iterator(f43d544532b4da60).(
2280 roaring_uint32_iterator_tcxx . . $ roaring_uint32_iterator_t# *it, uint32_tcxx . . $ uint32_t# *buf, uint32_tcxx . . $ uint32_t# count) {
2281 return roaring_uint32_iterator_readcxx . . $ roaring_uint32_iterator_read(f43d544532b4da60).(it, buf, count);
2282 }
2283
2284 #ifdef __cplusplus
2285 }
2286 }
2287 } // extern "C" { namespace roaring { namespace api {
2288 #endif
2289
2290 #endif /* ROARING_H */
2291
2292 #ifdef __cplusplus
2293 /**
2294 * Best practices for C++ headers is to avoid polluting global scope.
2295 * But for C compatibility when just `roaring.h` is included building as
2296 * C++, default to global access for the C public API.
2297 *
2298 * BUT when `roaring.hh` is included instead, it sets this flag. That way
2299 * explicit namespacing must be used to get the C functions.
2300 *
2301 * This is outside the include guard so that if you include BOTH headers,
2302 * the order won't matter; you still get the global definitions.
2303 */
2304 #if !defined(ROARING_API_NOT_IN_GLOBAL_NAMESPACE)
2305 using namespace ::roaring::api;
2306 #endif
2307 #endif
2308
2309 // roaring64 will include roaring.h, but we would
2310 // prefer to avoid having our users include roaring64.h
2311 // in addition to roaring.h.
2312 /* end file include/roaring/roaring.h */
2313 /* begin file include/roaring/memory.h */
2314 #ifndef INCLUDE_ROARING_MEMORY_H_cxx . . $ `gtk/roaring/roaring.h:2315:9`!
2315 #define INCLUDE_ROARING_MEMORY_H_cxx . . $ `gtk/roaring/roaring.h:2315:9`!
2316
2317 #include <stddef.h> // for size_t
2318
2319 #ifdef __cplusplus
2320 extern "C" {
2321 #endif
2322
2323 typedef void* (*roaring_malloc_pcxx . . $ roaring_malloc_p#)(size_t);
2324 typedef void* (*roaring_realloc_pcxx . . $ roaring_realloc_p#)(void*, size_t);
2325 typedef void* (*roaring_calloc_pcxx . . $ roaring_calloc_p#)(size_t, size_t);
2326 typedef void (*roaring_free_pcxx . . $ roaring_free_p#)(void*);
2327 typedef void* (*roaring_aligned_malloc_pcxx . . $ roaring_aligned_malloc_p#)(size_t, size_t);
2328 typedef void (*roaring_aligned_free_pcxx . . $ roaring_aligned_free_p#)(void*);
2329
2330 typedef struct roaring_memory_scxx . . $ roaring_memory_s# {
2331 roaring_malloc_pcxx . . $ roaring_malloc_p# malloccxx . . $ roaring_memory_s#malloc.;
2332 roaring_realloc_pcxx . . $ roaring_realloc_p# realloccxx . . $ roaring_memory_s#realloc.;
2333 roaring_calloc_pcxx . . $ roaring_calloc_p# calloccxx . . $ roaring_memory_s#calloc.;
2334 roaring_free_pcxx . . $ roaring_free_p# freecxx . . $ roaring_memory_s#free.;
2335 roaring_aligned_malloc_pcxx . . $ roaring_aligned_malloc_p# aligned_malloccxx . . $ roaring_memory_s#aligned_malloc.;
2336 roaring_aligned_free_pcxx . . $ roaring_aligned_free_p# aligned_freecxx . . $ roaring_memory_s#aligned_free.;
2337 } roaring_memory_tcxx . . $ roaring_memory_t#;
2338
2339 static void roaring_init_memory_hookcxx . . $ roaring_init_memory_hook(3023c66acad7026b).(roaring_memory_tcxx . . $ roaring_memory_t# memory_hook);
2340
2341 static void* roaring_malloccxx . . $ roaring_malloc(bfcfa4d6b7f7ef64).(size_t);
2342 static void* roaring_realloccxx . . $ roaring_realloc(417ab160f6baadc6).(void*, size_t);
2343 static void* roaring_calloccxx . . $ roaring_calloc(63a7bf2941bfcd7a).(size_t, size_t);
2344 static void roaring_freecxx . . $ roaring_free(5d22bdacc48458e8).(void*);
2345 static void* roaring_aligned_malloccxx . . $ roaring_aligned_malloc(63a7bf2941bfcd7a).(size_t, size_t);
2346 static void roaring_aligned_freecxx . . $ roaring_aligned_free(5d22bdacc48458e8).(void*);
2347
2348 #ifdef __cplusplus
2349 }
2350 #endif
2351
2352 #endif // INCLUDE_ROARING_MEMORY_H_
2353 /* end file include/roaring/memory.h */
2354 /* begin file include/roaring/roaring64.h */
2355 #ifndef ROARING64_Hcxx . . $ `gtk/roaring/roaring.h:2356:9`!
2356 #define ROARING64_Hcxx . . $ `gtk/roaring/roaring.h:2356:9`!
2357
2358 #include <stdbool.h>
2359 #include <stddef.h>
2360 #include <stdint.h>
2361
2362
2363 #ifdef __cplusplus
2364 extern "C" {
2365 namespace roaring {
2366 namespace api {
2367 #endif
2368
2369 typedef struct roaring64_bitmap_scxx . . $ roaring64_bitmap_s# roaring64_bitmap_tcxx . . $ roaring64_bitmap_t#;
2370 typedef uint64_tcxx . . $ uint64_t# roaring64_leaf_tcxx . . $ roaring64_leaf_t#;
2371 typedef struct roaring64_iterator_scxx . . $ roaring64_iterator_s# roaring64_iterator_tcxx . . $ roaring64_iterator_t#;
2372
2373 /**
2374 * A bit of context usable with `roaring64_bitmap_*_bulk()` functions.
2375 *
2376 * Should be initialized with `{0}` (or `memset()` to all zeros).
2377 * Callers should treat it as an opaque type.
2378 *
2379 * A context may only be used with a single bitmap (unless re-initialized to
2380 * zero), and any modification to a bitmap (other than modifications performed
2381 * with `_bulk()` functions with the context passed) will invalidate any
2382 * contexts associated with that bitmap.
2383 */
2384 typedef struct roaring64_bulk_context_scxx . . $ roaring64_bulk_context_s# {
2385 uint8_tcxx . . $ uint8_t# high_bytescxx . . $ roaring64_bulk_context_s#high_bytes.[6];
2386 roaring64_leaf_tcxx . . $ roaring64_leaf_t# *leafcxx . . $ roaring64_bulk_context_s#leaf.;
2387 } roaring64_bulk_context_tcxx . . $ roaring64_bulk_context_t#;
2388
2389 /**
2390 * Dynamically allocates a new bitmap (initially empty).
2391 * Client is responsible for calling `roaring64_bitmap_free()`.
2392 * The returned pointer may be NULL in case of errors.
2393 */
2394 static roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *roaring64_bitmap_createcxx . . $ roaring64_bitmap_create(f79ae028a08e3949).(void);
2395 static void roaring64_bitmap_freecxx . . $ roaring64_bitmap_free(854d596e6c58b883).(roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r);
2396
2397 /**
2398 * Returns a copy of a bitmap.
2399 * The returned pointer may be NULL in case of errors.
2400 */
2401 static roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *roaring64_bitmap_copycxx . . $ roaring64_bitmap_copy(b50c213b534f9596).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r);
2402
2403 /**
2404 * Creates a new bitmap of a pointer to N 64-bit integers.
2405 */
2406 static roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *roaring64_bitmap_of_ptrcxx . . $ roaring64_bitmap_of_ptr(b218290f095859bc).(size_t n_args,
2407 const uint64_tcxx . . $ uint64_t# *vals);
2408
2409 #ifdef __cplusplus
2410 /**
2411 * Creates a new bitmap which contains all values passed in as arguments.
2412 *
2413 * To create a bitmap from a variable number of arguments, use the
2414 * `roaring64_bitmap_of_ptr` function instead.
2415 */
2416 // Use an immediately invoked closure, capturing by reference
2417 // (in case __VA_ARGS__ refers to context outside the closure)
2418 // Include a 0 at the beginning of the array to make the array length > 0
2419 // (zero sized arrays are not valid in standard c/c++)
2420 #define roaring64_bitmap_from(...) \
2421 [&]() { \
2422 const uint64_t roaring64_bitmap_from_array[] = {0, __VA_ARGS__}; \
2423 return roaring64_bitmap_of_ptr( \
2424 (sizeof(roaring64_bitmap_from_array) / \
2425 sizeof(roaring64_bitmap_from_array[0])) - \
2426 1, \
2427 &roaring64_bitmap_from_array[1]); \
2428 }()
2429 #else
2430 /**
2431 * Creates a new bitmap which contains all values passed in as arguments.
2432 *
2433 * To create a bitmap from a variable number of arguments, use the
2434 * `roaring64_bitmap_of_ptr` function instead.
2435 */
2436 // While __VA_ARGS__ occurs twice in expansion, one of the times is in a sizeof
2437 // expression, which is an unevaluated context, so it's even safe in the case
2438 // where expressions passed have side effects (roaring64_bitmap_from(my_func(),
2439 // ++i))
2440 // Include a 0 at the beginning of the array to make the array length > 0
2441 // (zero sized arrays are not valid in standard c/c++)
2442 #define roaring64_bitmap_fromcxx . . $ `gtk/roaring/roaring.h:2442:9`!(...) \
2443 roaring64_bitmap_of_ptr( \
2444 (sizeof((const uint64_t[]){0, __VA_ARGS__}) / sizeof(uint64_t)) - 1, \
2445 &((const uint64_t[]){0, __VA_ARGS__})[1])
2446 #endif
2447
2448 /**
2449 * Create a new bitmap by moving containers from a 32 bit roaring bitmap.
2450 *
2451 * After calling this function, the original bitmap will be empty, and the
2452 * returned bitmap will contain all the values from the original bitmap.
2453 */
2454 static roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *roaring64_bitmap_move_from_roaring32cxx . . $ roaring64_bitmap_move_from_roaring32(1c54a01b7c3c08c7).(roaring_bitmap_tcxx . . $ roaring_bitmap_t# *r);
2455
2456 /**
2457 * Create a new bitmap containing all the values in [min, max) that are at a
2458 * distance k*step from min.
2459 * The returned pointer may be NULL in case of errors.
2460 */
2461 static roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *roaring64_bitmap_from_rangecxx . . $ roaring64_bitmap_from_range(8185b22bed6bf476).(uint64_tcxx . . $ uint64_t# min, uint64_tcxx . . $ uint64_t# max,
2462 uint64_tcxx . . $ uint64_t# step);
2463
2464 /**
2465 * Adds the provided value to the bitmap.
2466 */
2467 static void roaring64_bitmap_addcxx . . $ roaring64_bitmap_add(18ccf7fc53960ea3).(roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r, uint64_tcxx . . $ uint64_t# val);
2468
2469 /**
2470 * Adds the provided value to the bitmap.
2471 * Returns true if a new value was added, false if the value already existed.
2472 */
2473 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring64_bitmap_add_checkedcxx . . $ roaring64_bitmap_add_checked(b1bde3e5ffc7a3e6).(roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r, uint64_tcxx . . $ uint64_t# val);
2474
2475 /**
2476 * Add an item, using context from a previous insert for faster insertion.
2477 *
2478 * `context` will be used to store information between calls to make bulk
2479 * operations faster. `*context` should be zero-initialized before the first
2480 * call to this function.
2481 *
2482 * Modifying the bitmap in any way (other than `-bulk` suffixed functions)
2483 * will invalidate the stored context, calling this function with a non-zero
2484 * context after doing any modification invokes undefined behavior.
2485 *
2486 * In order to exploit this optimization, the caller should call this function
2487 * with values with the same high 48 bits of the value consecutively.
2488 */
2489 static void roaring64_bitmap_add_bulkcxx . . $ roaring64_bitmap_add_bulk(c47494926e759491).(roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r,
2490 roaring64_bulk_context_tcxx . . $ roaring64_bulk_context_t# *context, uint64_tcxx . . $ uint64_t# val);
2491
2492 /**
2493 * Add `n_args` values from `vals`, faster than repeatedly calling
2494 * `roaring64_bitmap_add()`
2495 *
2496 * In order to exploit this optimization, the caller should attempt to keep
2497 * values with the same high 48 bits of the value as consecutive elements in
2498 * `vals`.
2499 */
2500 static void roaring64_bitmap_add_manycxx . . $ roaring64_bitmap_add_many(7b785ba8fd7117ae).(roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r, size_t n_args,
2501 const uint64_tcxx . . $ uint64_t# *vals);
2502
2503 /**
2504 * Add all values in range [min, max).
2505 */
2506 static void roaring64_bitmap_add_rangecxx . . $ roaring64_bitmap_add_range(630ddbe541bf11b8).(roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r, uint64_tcxx . . $ uint64_t# min,
2507 uint64_tcxx . . $ uint64_t# max);
2508
2509 /**
2510 * Add all values in range [min, max].
2511 */
2512 static void roaring64_bitmap_add_range_closedcxx . . $ roaring64_bitmap_add_range_closed(630ddbe541bf11b8).(roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r, uint64_tcxx . . $ uint64_t# min,
2513 uint64_tcxx . . $ uint64_t# max);
2514
2515 /**
2516 * Removes a value from the bitmap if present.
2517 */
2518 static void roaring64_bitmap_removecxx . . $ roaring64_bitmap_remove(18ccf7fc53960ea3).(roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r, uint64_tcxx . . $ uint64_t# val);
2519
2520 /**
2521 * Removes a value from the bitmap if present, returns true if the value was
2522 * removed and false if the value was not present.
2523 */
2524 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring64_bitmap_remove_checkedcxx . . $ roaring64_bitmap_remove_checked(b1bde3e5ffc7a3e6).(roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r, uint64_tcxx . . $ uint64_t# val);
2525
2526 /**
2527 * Remove an item, using context from a previous insert for faster removal.
2528 *
2529 * `context` will be used to store information between calls to make bulk
2530 * operations faster. `*context` should be zero-initialized before the first
2531 * call to this function.
2532 *
2533 * Modifying the bitmap in any way (other than `-bulk` suffixed functions)
2534 * will invalidate the stored context, calling this function with a non-zero
2535 * context after doing any modification invokes undefined behavior.
2536 *
2537 * In order to exploit this optimization, the caller should call this function
2538 * with values with the same high 48 bits of the value consecutively.
2539 */
2540 static void roaring64_bitmap_remove_bulkcxx . . $ roaring64_bitmap_remove_bulk(c47494926e759491).(roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r,
2541 roaring64_bulk_context_tcxx . . $ roaring64_bulk_context_t# *context,
2542 uint64_tcxx . . $ uint64_t# val);
2543
2544 /**
2545 * Remove `n_args` values from `vals`, faster than repeatedly calling
2546 * `roaring64_bitmap_remove()`
2547 *
2548 * In order to exploit this optimization, the caller should attempt to keep
2549 * values with the same high 48 bits of the value as consecutive elements in
2550 * `vals`.
2551 */
2552 static void roaring64_bitmap_remove_manycxx . . $ roaring64_bitmap_remove_many(7b785ba8fd7117ae).(roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r, size_t n_args,
2553 const uint64_tcxx . . $ uint64_t# *vals);
2554
2555 /**
2556 * Remove all values in range [min, max).
2557 */
2558 static void roaring64_bitmap_remove_rangecxx . . $ roaring64_bitmap_remove_range(630ddbe541bf11b8).(roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r, uint64_tcxx . . $ uint64_t# min,
2559 uint64_tcxx . . $ uint64_t# max);
2560
2561 /**
2562 * Remove all values in range [min, max].
2563 */
2564 static void roaring64_bitmap_remove_range_closedcxx . . $ roaring64_bitmap_remove_range_closed(630ddbe541bf11b8).(roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r, uint64_tcxx . . $ uint64_t# min,
2565 uint64_tcxx . . $ uint64_t# max);
2566
2567 /**
2568 * Empties the bitmap.
2569 */
2570 static void roaring64_bitmap_clearcxx . . $ roaring64_bitmap_clear(854d596e6c58b883).(roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r);
2571
2572 /**
2573 * Returns true if the provided value is present.
2574 */
2575 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring64_bitmap_containscxx . . $ roaring64_bitmap_contains(4a80f221965a04ed).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r, uint64_tcxx . . $ uint64_t# val);
2576
2577 /**
2578 * Returns true if all values in the range [min, max) are present.
2579 */
2580 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring64_bitmap_contains_rangecxx . . $ roaring64_bitmap_contains_range(8d1b30ba4539f33b).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r, uint64_tcxx . . $ uint64_t# min,
2581 uint64_tcxx . . $ uint64_t# max);
2582
2583 /**
2584 * Check if an item is present using context from a previous insert or search
2585 * for faster search.
2586 *
2587 * `context` will be used to store information between calls to make bulk
2588 * operations faster. `*context` should be zero-initialized before the first
2589 * call to this function.
2590 *
2591 * Modifying the bitmap in any way (other than `-bulk` suffixed functions)
2592 * will invalidate the stored context, calling this function with a non-zero
2593 * context after doing any modification invokes undefined behavior.
2594 *
2595 * In order to exploit this optimization, the caller should call this function
2596 * with values with the same high 48 bits of the value consecutively.
2597 */
2598 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring64_bitmap_contains_bulkcxx . . $ roaring64_bitmap_contains_bulk(8492ebf4dfeefc92).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r,
2599 roaring64_bulk_context_tcxx . . $ roaring64_bulk_context_t# *context,
2600 uint64_tcxx . . $ uint64_t# val);
2601
2602 /**
2603 * Selects the element at index 'rank' where the smallest element is at index 0.
2604 * If the size of the bitmap is strictly greater than rank, then this function
2605 * returns true and sets element to the element of given rank. Otherwise, it
2606 * returns false.
2607 */
2608 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring64_bitmap_selectcxx . . $ roaring64_bitmap_select(2bc44d90a8f7b081).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r, uint64_tcxx . . $ uint64_t# rank,
2609 uint64_tcxx . . $ uint64_t# *element);
2610
2611 /**
2612 * Returns the number of integers that are smaller or equal to x. Thus if x is
2613 * the first element, this function will return 1. If x is smaller than the
2614 * smallest element, this function will return 0.
2615 *
2616 * The indexing convention differs between roaring64_bitmap_select and
2617 * roaring64_bitmap_rank: roaring_bitmap64_select refers to the smallest value
2618 * as having index 0, whereas roaring64_bitmap_rank returns 1 when ranking
2619 * the smallest value.
2620 */
2621 static uint64_tcxx . . $ uint64_t# roaring64_bitmap_rankcxx . . $ roaring64_bitmap_rank(a475826afcab5e6b).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r, uint64_tcxx . . $ uint64_t# val);
2622
2623 /**
2624 * Returns true if the given value is in the bitmap, and sets `out_index` to the
2625 * (0-based) index of the value in the bitmap. Returns false if the value is not
2626 * in the bitmap.
2627 */
2628 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring64_bitmap_get_indexcxx . . $ roaring64_bitmap_get_index(2bc44d90a8f7b081).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r, uint64_tcxx . . $ uint64_t# val,
2629 uint64_tcxx . . $ uint64_t# *out_index);
2630
2631 /**
2632 * Returns the number of values in the bitmap.
2633 */
2634 static uint64_tcxx . . $ uint64_t# roaring64_bitmap_get_cardinalitycxx . . $ roaring64_bitmap_get_cardinality(a77e186bd12e2f6e).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r);
2635
2636 /**
2637 * Returns the number of elements in the range [min, max).
2638 */
2639 static uint64_tcxx . . $ uint64_t# roaring64_bitmap_range_cardinalitycxx . . $ roaring64_bitmap_range_cardinality(bdc4e9dc54de7df5).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r,
2640 uint64_tcxx . . $ uint64_t# min, uint64_tcxx . . $ uint64_t# max);
2641
2642 /**
2643 * Returns the number of elements in the range [min, max]
2644 */
2645 static uint64_tcxx . . $ uint64_t# roaring64_bitmap_range_closed_cardinalitycxx . . $ roaring64_bitmap_range_closed_cardinality(bdc4e9dc54de7df5).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r,
2646 uint64_tcxx . . $ uint64_t# min, uint64_tcxx . . $ uint64_t# max);
2647
2648 /**
2649 * Returns true if the bitmap is empty (cardinality is zero).
2650 */
2651 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring64_bitmap_is_emptycxx . . $ roaring64_bitmap_is_empty(79ba4304986bc27).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r);
2652
2653 /**
2654 * Returns the smallest value in the set, or UINT64_MAX if the set is empty.
2655 */
2656 static uint64_tcxx . . $ uint64_t# roaring64_bitmap_minimumcxx . . $ roaring64_bitmap_minimum(a77e186bd12e2f6e).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r);
2657
2658 /**
2659 * Returns the largest value in the set, or 0 if empty.
2660 */
2661 static uint64_tcxx . . $ uint64_t# roaring64_bitmap_maximumcxx . . $ roaring64_bitmap_maximum(a77e186bd12e2f6e).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r);
2662
2663 /**
2664 * Returns true if the result has at least one run container.
2665 */
2666 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring64_bitmap_run_optimizecxx . . $ roaring64_bitmap_run_optimize(fb707424f5e17648).(roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r);
2667
2668 /**
2669 * Shrinks internal arrays to eliminate any unused capacity. Returns the number
2670 * of bytes freed.
2671 */
2672 static size_t roaring64_bitmap_shrink_to_fitcxx . . $ roaring64_bitmap_shrink_to_fit(ac2ff550426fafb4).(roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r);
2673
2674 /**
2675 * (For advanced users.)
2676 * Collect statistics about the bitmap
2677 */
2678 static void roaring64_bitmap_statisticscxx . . $ roaring64_bitmap_statistics(3193e7b4461bdc38).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r,
2679 roaring64_statistics_tcxx . . $ roaring64_statistics_t# *stat);
2680
2681 /**
2682 * Perform internal consistency checks.
2683 *
2684 * Returns true if the bitmap is consistent. It may be useful to call this
2685 * after deserializing bitmaps from untrusted sources. If
2686 * roaring64_bitmap_internal_validate returns true, then the bitmap is
2687 * consistent and can be trusted not to cause crashes or memory corruption.
2688 *
2689 * If reason is non-null, it will be set to a string describing the first
2690 * inconsistency found if any.
2691 */
2692 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring64_bitmap_internal_validatecxx . . $ roaring64_bitmap_internal_validate(204c898dff99e14).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r,
2693 const char **reason);
2694
2695 /**
2696 * Return true if the two bitmaps contain the same elements.
2697 */
2698 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring64_bitmap_equalscxx . . $ roaring64_bitmap_equals(a2673b26f0247265).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r1,
2699 const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r2);
2700
2701 /**
2702 * Return true if all the elements of r1 are also in r2.
2703 */
2704 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring64_bitmap_is_subsetcxx . . $ roaring64_bitmap_is_subset(a2673b26f0247265).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r1,
2705 const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r2);
2706
2707 /**
2708 * Return true if all the elements of r1 are also in r2, and r2 is strictly
2709 * greater than r1.
2710 */
2711 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring64_bitmap_is_strict_subsetcxx . . $ roaring64_bitmap_is_strict_subset(a2673b26f0247265).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r1,
2712 const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r2);
2713
2714 /**
2715 * Computes the intersection between two bitmaps and returns new bitmap. The
2716 * caller is responsible for free-ing the result.
2717 *
2718 * Performance hint: if you are computing the intersection between several
2719 * bitmaps, two-by-two, it is best to start with the smallest bitmaps. You may
2720 * also rely on roaring64_bitmap_and_inplace to avoid creating many temporary
2721 * bitmaps.
2722 *
2723 * The returned pointer may be NULL in case of errors.
2724 */
2725 static roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *roaring64_bitmap_andcxx . . $ roaring64_bitmap_and(b2308e4a755d4c35).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r1,
2726 const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r2);
2727
2728 /**
2729 * Computes the size of the intersection between two bitmaps.
2730 */
2731 static uint64_tcxx . . $ uint64_t# roaring64_bitmap_and_cardinalitycxx . . $ roaring64_bitmap_and_cardinality(2d81ba2c8158611f).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r1,
2732 const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r2);
2733
2734 /**
2735 * In-place version of `roaring64_bitmap_and()`, modifies `r1`. `r1` and `r2`
2736 * are allowed to be equal.
2737 *
2738 * Performance hint: if you are computing the intersection between several
2739 * bitmaps, two-by-two, it is best to start with the smallest bitmaps.
2740 */
2741 static void roaring64_bitmap_and_inplacecxx . . $ roaring64_bitmap_and_inplace(bf735d0cf1a05968).(roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r1,
2742 const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r2);
2743
2744 /**
2745 * Check whether two bitmaps intersect.
2746 */
2747 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring64_bitmap_intersectcxx . . $ roaring64_bitmap_intersect(a2673b26f0247265).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r1,
2748 const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r2);
2749
2750 /**
2751 * Check whether a bitmap intersects the range [min, max).
2752 */
2753 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring64_bitmap_intersect_with_rangecxx . . $ roaring64_bitmap_intersect_with_range(8d1b30ba4539f33b).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r,
2754 uint64_tcxx . . $ uint64_t# min, uint64_tcxx . . $ uint64_t# max);
2755
2756 /**
2757 * Computes the Jaccard index between two bitmaps. (Also known as the Tanimoto
2758 * distance, or the Jaccard similarity coefficient)
2759 *
2760 * The Jaccard index is undefined if both bitmaps are empty.
2761 */
2762 static double roaring64_bitmap_jaccard_indexcxx . . $ roaring64_bitmap_jaccard_index(e0c698e03d69c14b).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r1,
2763 const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r2);
2764
2765 /**
2766 * Computes the union between two bitmaps and returns new bitmap. The caller is
2767 * responsible for free-ing the result.
2768 * The returned pointer may be NULL in case of errors.
2769 */
2770 static roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *roaring64_bitmap_orcxx . . $ roaring64_bitmap_or(b2308e4a755d4c35).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r1,
2771 const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r2);
2772
2773 /**
2774 * Computes the size of the union between two bitmaps.
2775 */
2776 static uint64_tcxx . . $ uint64_t# roaring64_bitmap_or_cardinalitycxx . . $ roaring64_bitmap_or_cardinality(2d81ba2c8158611f).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r1,
2777 const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r2);
2778
2779 /**
2780 * In-place version of `roaring64_bitmap_or(), modifies `r1`.
2781 */
2782 static void roaring64_bitmap_or_inplacecxx . . $ roaring64_bitmap_or_inplace(bf735d0cf1a05968).(roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r1,
2783 const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r2);
2784
2785 /**
2786 * Computes the symmetric difference (xor) between two bitmaps and returns a new
2787 * bitmap. The caller is responsible for free-ing the result.
2788 * The returned pointer may be NULL in case of errors.
2789 */
2790 static roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *roaring64_bitmap_xorcxx . . $ roaring64_bitmap_xor(b2308e4a755d4c35).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r1,
2791 const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r2);
2792
2793 /**
2794 * Computes the size of the symmetric difference (xor) between two bitmaps.
2795 */
2796 static uint64_tcxx . . $ uint64_t# roaring64_bitmap_xor_cardinalitycxx . . $ roaring64_bitmap_xor_cardinality(2d81ba2c8158611f).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r1,
2797 const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r2);
2798
2799 /**
2800 * In-place version of `roaring64_bitmap_xor()`, modifies `r1`. `r1` and `r2`
2801 * are not allowed to be equal (that would result in an empty bitmap).
2802 */
2803 static void roaring64_bitmap_xor_inplacecxx . . $ roaring64_bitmap_xor_inplace(bf735d0cf1a05968).(roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r1,
2804 const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r2);
2805
2806 /**
2807 * Computes the difference (andnot) between two bitmaps and returns a new
2808 * bitmap. The caller is responsible for free-ing the result.
2809 * The returned pointer may be NULL in case of errors.
2810 */
2811 static roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *roaring64_bitmap_andnotcxx . . $ roaring64_bitmap_andnot(b2308e4a755d4c35).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r1,
2812 const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r2);
2813
2814 /**
2815 * Computes the size of the difference (andnot) between two bitmaps.
2816 */
2817 static uint64_tcxx . . $ uint64_t# roaring64_bitmap_andnot_cardinalitycxx . . $ roaring64_bitmap_andnot_cardinality(2d81ba2c8158611f).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r1,
2818 const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r2);
2819
2820 /**
2821 * In-place version of `roaring64_bitmap_andnot()`, modifies `r1`. `r1` and `r2`
2822 * are not allowed to be equal (that would result in an empty bitmap).
2823 */
2824 static void roaring64_bitmap_andnot_inplacecxx . . $ roaring64_bitmap_andnot_inplace(bf735d0cf1a05968).(roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r1,
2825 const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r2);
2826
2827 /**
2828 * Compute the negation of the bitmap in the interval [min, max).
2829 * The number of negated values is `max - min`. Areas outside the range are
2830 * passed through unchanged.
2831 * The returned pointer may be NULL in case of errors.
2832 */
2833 static roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *roaring64_bitmap_flipcxx . . $ roaring64_bitmap_flip(aa441407182d9dc4).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r,
2834 uint64_tcxx . . $ uint64_t# min, uint64_tcxx . . $ uint64_t# max);
2835
2836 /**
2837 * Compute the negation of the bitmap in the interval [min, max].
2838 * The number of negated values is `max - min + 1`. Areas outside the range are
2839 * passed through unchanged.
2840 * The returned pointer may be NULL in case of errors.
2841 */
2842 static roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *roaring64_bitmap_flip_closedcxx . . $ roaring64_bitmap_flip_closed(aa441407182d9dc4).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r,
2843 uint64_tcxx . . $ uint64_t# min, uint64_tcxx . . $ uint64_t# max);
2844
2845 /**
2846 * In-place version of `roaring64_bitmap_flip`. Compute the negation of the
2847 * bitmap in the interval [min, max). The number of negated values is `max -
2848 * min`. Areas outside the range are passed through unchanged.
2849 */
2850 static void roaring64_bitmap_flip_inplacecxx . . $ roaring64_bitmap_flip_inplace(630ddbe541bf11b8).(roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r, uint64_tcxx . . $ uint64_t# min,
2851 uint64_tcxx . . $ uint64_t# max);
2852 /**
2853 * In-place version of `roaring64_bitmap_flip_closed`. Compute the negation of
2854 * the bitmap in the interval [min, max]. The number of negated values is `max -
2855 * min + 1`. Areas outside the range are passed through unchanged.
2856 */
2857 static void roaring64_bitmap_flip_closed_inplacecxx . . $ roaring64_bitmap_flip_closed_inplace(630ddbe541bf11b8).(roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r, uint64_tcxx . . $ uint64_t# min,
2858 uint64_tcxx . . $ uint64_t# max);
2859 /**
2860 * How many bytes are required to serialize this bitmap.
2861 *
2862 * This is meant to be compatible with other languages:
2863 * https://github.com/RoaringBitmap/RoaringFormatSpec#extension-for-64-bit-implementations
2864 */
2865 static size_t roaring64_bitmap_portable_size_in_bytescxx . . $ roaring64_bitmap_portable_size_in_bytes(a77e186bd12e2f6e).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r);
2866
2867 /**
2868 * Write a bitmap to a buffer. The output buffer should refer to at least
2869 * `roaring64_bitmap_portable_size_in_bytes(r)` bytes of allocated memory.
2870 *
2871 * Returns how many bytes were written, which should match
2872 * `roaring64_bitmap_portable_size_in_bytes(r)`.
2873 *
2874 * This is meant to be compatible with other languages:
2875 * https://github.com/RoaringBitmap/RoaringFormatSpec#extension-for-64-bit-implementations
2876 *
2877 * This function is endian-sensitive. If you have a big-endian system (e.g., a
2878 * mainframe IBM s390x), the data format is going to be big-endian and not
2879 * compatible with little-endian systems.
2880 *
2881 * When serializing data to a file, we recommend that you also use
2882 * checksums so that, at deserialization, you can be confident
2883 * that you are recovering the correct data.
2884 */
2885 static size_t roaring64_bitmap_portable_serializecxx . . $ roaring64_bitmap_portable_serialize(4ea0a8900d92a1ff).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r,
2886 char *buf);
2887 /**
2888 * Check how many bytes would be read (up to maxbytes) at this pointer if there
2889 * is a valid bitmap, returns zero if there is no valid bitmap.
2890 *
2891 * This is meant to be compatible with other languages
2892 * https://github.com/RoaringBitmap/RoaringFormatSpec#extension-for-64-bit-implementations
2893 */
2894 static size_t roaring64_bitmap_portable_deserialize_sizecxx . . $ roaring64_bitmap_portable_deserialize_size(ac5a385650b4bde5).(const char *buf,
2895 size_t maxbytes);
2896
2897 /**
2898 * Read a bitmap from a serialized buffer (reading up to maxbytes).
2899 * In case of failure, NULL is returned.
2900 *
2901 * This is meant to be compatible with other languages
2902 * https://github.com/RoaringBitmap/RoaringFormatSpec#extension-for-64-bit-implementations
2903 *
2904 * The function itself is safe in the sense that it will not cause buffer
2905 * overflows: it will not read beyond the scope of the provided buffer
2906 * (buf,maxbytes).
2907 *
2908 * However, for correct operations, it is assumed that the bitmap
2909 * read was once serialized from a valid bitmap (i.e., it follows the format
2910 * specification). If you provided an incorrect input (garbage), then the bitmap
2911 * read may not be in a valid state and following operations may not lead to
2912 * sensible results. In particular, the serialized array containers need to be
2913 * in sorted order, and the run containers should be in sorted non-overlapping
2914 * order. This is is guaranteed to happen when serializing an existing bitmap,
2915 * but not for random inputs.
2916 *
2917 * If the source is untrusted, you should call
2918 * roaring64_bitmap_internal_validate to check the validity of the
2919 * bitmap prior to using it. Only after calling
2920 * roaring64_bitmap_internal_validate is the bitmap considered safe for use.
2921 *
2922 * We also recommend that you use checksums to check that serialized data
2923 * corresponds to the serialized bitmap. The CRoaring library does not provide
2924 * checksumming.
2925 *
2926 * This function is endian-sensitive. If you have a big-endian system (e.g., a
2927 * mainframe IBM s390x), the data format is going to be big-endian and not
2928 * compatible with little-endian systems.
2929 */
2930 static roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *roaring64_bitmap_portable_deserialize_safecxx . . $ roaring64_bitmap_portable_deserialize_safe(5b674e533f8e952e).(const char *buf,
2931 size_t maxbytes);
2932
2933 /**
2934 * Returns the number of bytes required to serialize this bitmap in a "frozen"
2935 * format. This is not compatible with any other serialization formats.
2936 *
2937 * `roaring64_bitmap_shrink_to_fit()` must be called before this method.
2938 */
2939 static size_t roaring64_bitmap_frozen_size_in_bytescxx . . $ roaring64_bitmap_frozen_size_in_bytes(a77e186bd12e2f6e).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r);
2940
2941 /**
2942 * Serializes the bitmap in a "frozen" format. The given buffer must be at least
2943 * `roaring64_bitmap_frozen_size_in_bytes()` in size. Returns the number of
2944 * bytes used for serialization.
2945 *
2946 * `roaring64_bitmap_shrink_to_fit()` must be called before this method.
2947 *
2948 * The frozen format is optimized for speed of (de)serialization, as well as
2949 * allowing the user to create a bitmap based on a memory mapped file, which is
2950 * possible because the format mimics the memory layout of the bitmap.
2951 *
2952 * Because the format mimics the memory layout of the bitmap, the format is not
2953 * fixed across releases of Roaring Bitmaps, and may change in future releases.
2954 *
2955 * This function is endian-sensitive. If you have a big-endian system (e.g., a
2956 * mainframe IBM s390x), the data format is going to be big-endian and not
2957 * compatible with little-endian systems.
2958 */
2959 static size_t roaring64_bitmap_frozen_serializecxx . . $ roaring64_bitmap_frozen_serialize(4ea0a8900d92a1ff).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r,
2960 char *buf);
2961
2962 /**
2963 * Creates a readonly bitmap that is a view of the given buffer. The buffer
2964 * must be created with `roaring64_bitmap_frozen_serialize()`, and must be
2965 * aligned by 64 bytes.
2966 *
2967 * Returns NULL if deserialization fails.
2968 *
2969 * The returned bitmap must only be used in a readonly manner. The bitmap must
2970 * be freed using `roaring64_bitmap_free()` as normal. The backing buffer must
2971 * only be freed after the bitmap.
2972 *
2973 * This function is endian-sensitive. If you have a big-endian system (e.g., a
2974 * mainframe IBM s390x), the data format is going to be big-endian and not
2975 * compatible with little-endian systems.
2976 */
2977 static roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *roaring64_bitmap_frozen_viewcxx . . $ roaring64_bitmap_frozen_view(5b674e533f8e952e).(const char *buf,
2978 size_t maxbytes);
2979
2980 /**
2981 * Iterate over the bitmap elements. The function `iterator` is called once for
2982 * all the values with `ptr` (can be NULL) as the second parameter of each call.
2983 *
2984 * `roaring_iterator64` is simply a pointer to a function that returns a bool
2985 * and takes `(uint64_t, void*)` as inputs. True means that the iteration should
2986 * continue, while false means that it should stop.
2987 *
2988 * Returns true if the `roaring64_iterator` returned true throughout (so that
2989 * all data points were necessarily visited).
2990 *
2991 * Iteration is ordered from the smallest to the largest elements.
2992 */
2993 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring64_bitmap_iteratecxx . . $ roaring64_bitmap_iterate(76eccfc1f87d0433).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r,
2994 roaring_iterator64cxx . . $ roaring_iterator64# iterator, void *ptr);
2995
2996 /**
2997 * Convert the bitmap to a sorted array `out`.
2998 *
2999 * Caller is responsible to ensure that there is enough memory allocated, e.g.
3000 * ```
3001 * out = malloc(roaring64_bitmap_get_cardinality(bitmap) * sizeof(uint64_t));
3002 * ```
3003 */
3004 static void roaring64_bitmap_to_uint64_arraycxx . . $ roaring64_bitmap_to_uint64_array(68eb8507cb58966b).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r,
3005 uint64_tcxx . . $ uint64_t# *out);
3006
3007 /**
3008 * Create an iterator object that can be used to iterate through the values.
3009 * Caller is responsible for calling `roaring64_iterator_free()`.
3010 *
3011 * The iterator is initialized. If there is a value, then this iterator points
3012 * to the first value and `roaring64_iterator_has_value()` returns true. The
3013 * value can be retrieved with `roaring64_iterator_value()`.
3014 */
3015 static roaring64_iterator_tcxx . . $ roaring64_iterator_t# *roaring64_iterator_createcxx . . $ roaring64_iterator_create(74b671a228edcc8d).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r);
3016
3017 /**
3018 * Create an iterator object that can be used to iterate through the values.
3019 * Caller is responsible for calling `roaring64_iterator_free()`.
3020 *
3021 * The iterator is initialized. If there is a value, then this iterator points
3022 * to the last value and `roaring64_iterator_has_value()` returns true. The
3023 * value can be retrieved with `roaring64_iterator_value()`.
3024 */
3025 static roaring64_iterator_tcxx . . $ roaring64_iterator_t# *roaring64_iterator_create_lastcxx . . $ roaring64_iterator_create_last(74b671a228edcc8d).(
3026 const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r);
3027
3028 /**
3029 * Re-initializes an existing iterator. Functionally the same as
3030 * `roaring64_iterator_create` without a allocation.
3031 */
3032 static void roaring64_iterator_reinitcxx . . $ roaring64_iterator_reinit(2dc6fdabf5730ad2).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r,
3033 roaring64_iterator_tcxx . . $ roaring64_iterator_t# *it);
3034
3035 /**
3036 * Re-initializes an existing iterator. Functionally the same as
3037 * `roaring64_iterator_create_last` without a allocation.
3038 */
3039 static void roaring64_iterator_reinit_lastcxx . . $ roaring64_iterator_reinit_last(2dc6fdabf5730ad2).(const roaring64_bitmap_tcxx . . $ roaring64_bitmap_t# *r,
3040 roaring64_iterator_tcxx . . $ roaring64_iterator_t# *it);
3041
3042 /**
3043 * Creates a copy of the iterator. Caller is responsible for calling
3044 * `roaring64_iterator_free()` on the resulting iterator.
3045 */
3046 static roaring64_iterator_tcxx . . $ roaring64_iterator_t# *roaring64_iterator_copycxx . . $ roaring64_iterator_copy(1b6f6474e16d6552).(const roaring64_iterator_tcxx . . $ roaring64_iterator_t# *it);
3047
3048 /**
3049 * Free the iterator.
3050 */
3051 static void roaring64_iterator_freecxx . . $ roaring64_iterator_free(c2dfcc8ce3b74dbe).(roaring64_iterator_tcxx . . $ roaring64_iterator_t# *it);
3052
3053 /**
3054 * Returns true if the iterator currently points to a value. If so, calling
3055 * `roaring64_iterator_value()` returns the value.
3056 */
3057 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring64_iterator_has_valuecxx . . $ roaring64_iterator_has_value(63ba3fc5af0f5841).(const roaring64_iterator_tcxx . . $ roaring64_iterator_t# *it);
3058
3059 /**
3060 * Returns the value the iterator currently points to. Should only be called if
3061 * `roaring64_iterator_has_value()` returns true.
3062 */
3063 static uint64_tcxx . . $ uint64_t# roaring64_iterator_valuecxx . . $ roaring64_iterator_value(595623a4cc49dc8).(const roaring64_iterator_tcxx . . $ roaring64_iterator_t# *it);
3064
3065 /**
3066 * Advance the iterator. If there is a new value, then
3067 * `roaring64_iterator_has_value()` returns true. Values are traversed in
3068 * increasing order. For convenience, returns the result of
3069 * `roaring64_iterator_has_value()`.
3070 *
3071 * Once this returns false, `roaring64_iterator_advance` should not be called on
3072 * the iterator again. Calling `roaring64_iterator_previous` is allowed.
3073 */
3074 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring64_iterator_advancecxx . . $ roaring64_iterator_advance(c95761846ad53a33).(roaring64_iterator_tcxx . . $ roaring64_iterator_t# *it);
3075
3076 /**
3077 * Decrement the iterator. If there is a new value, then
3078 * `roaring64_iterator_has_value()` returns true. Values are traversed in
3079 * decreasing order. For convenience, returns the result of
3080 * `roaring64_iterator_has_value()`.
3081 *
3082 * Once this returns false, `roaring64_iterator_previous` should not be called
3083 * on the iterator again. Calling `roaring64_iterator_advance` is allowed.
3084 */
3085 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring64_iterator_previouscxx . . $ roaring64_iterator_previous(c95761846ad53a33).(roaring64_iterator_tcxx . . $ roaring64_iterator_t# *it);
3086
3087 /**
3088 * Move the iterator to the first value greater than or equal to `val`, if it
3089 * exists at or after the current position of the iterator. If there is a new
3090 * value, then `roaring64_iterator_has_value()` returns true. Values are
3091 * traversed in increasing order. For convenience, returns the result of
3092 * `roaring64_iterator_has_value()`.
3093 */
3094 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! roaring64_iterator_move_equalorlargercxx . . $ roaring64_iterator_move_equalorlarger(2cc070a9991f7712).(roaring64_iterator_tcxx . . $ roaring64_iterator_t# *it,
3095 uint64_tcxx . . $ uint64_t# val);
3096
3097 /**
3098 * Reads up to `count` values from the iterator into the given `buf`. Returns
3099 * the number of elements read. The number of elements read can be smaller than
3100 * `count`, which means that there are no more elements in the bitmap.
3101 *
3102 * This function can be used together with other iterator functions.
3103 */
3104 static uint64_tcxx . . $ uint64_t# roaring64_iterator_readcxx . . $ roaring64_iterator_read(abc59cc9b24524bc).(roaring64_iterator_tcxx . . $ roaring64_iterator_t# *it, uint64_tcxx . . $ uint64_t# *buf,
3105 uint64_tcxx . . $ uint64_t# count);
3106
3107 #ifdef __cplusplus
3108 } // extern "C"
3109 } // namespace roaring
3110 } // namespace api
3111 #endif
3112
3113 #endif /* ROARING64_H */
3114 /* end file include/roaring/roaring64.h */