Adds the provided value to the bitmap.
Add an item, using context from a previous insert for faster insertion.
Adds the provided value to the bitmap.
Returns true if a new value was added, false if the value already existed.
Add n_args
values from vals
, faster than repeatedly calling
roaring64_bitmap_add()
Add all values in range [min, max).
Add all values in range [min, max].
Computes the intersection between two bitmaps and returns new bitmap. The
caller is responsible for free-ing the result.
Computes the size of the intersection between two bitmaps.
In-place version of roaring64_bitmap_and()
, modifies r1
. r1
and r2
are allowed to be equal.
Computes the difference (andnot) between two bitmaps and returns a new
bitmap. The caller is responsible for free-ing the result.
Computes the size of the difference (andnot) between two bitmaps.
In-place version of roaring64_bitmap_andnot()
, modifies r1
. r1
and r2
are not allowed to be equal (that would result in an empty bitmap).
Returns true if the provided value is present.
Check if an item is present using context from a previous insert or search
for faster search.
Returns true if all values in the range [min, max) are present.
Returns a copy of a bitmap.
Dynamically allocates a new bitmap (initially empty).
Client is responsible for calling roaring64_bitmap_free()
.
Return true if the two bitmaps contain the same elements.
Compute the negation of the bitmap in the interval [min, max).
The number of negated values is max - min
. Areas outside the range are
passed through unchanged.
Compute the negation of the bitmap in the interval [min, max].
The number of negated values is max - min + 1
. Areas outside the range are
passed through unchanged.
In-place version of roaring64_bitmap_flip_closed
. Compute the negation of
the bitmap in the interval [min, max]. The number of negated values is max - min + 1
. Areas outside the range are passed through unchanged.
In-place version of roaring64_bitmap_flip
. Compute the negation of the
bitmap in the interval [min, max). The number of negated values is max - min
. Areas outside the range are passed through unchanged.
Create a new bitmap containing all the values in [min, max) that are at a
distance k*step from min.
Returns the number of values in the bitmap.
Returns true if the given value is in the bitmap, and sets out_index
to the
(0-based) index of the value in the bitmap. Returns false if the value is not
in the bitmap.
Perform internal consistency checks.
Check whether two bitmaps intersect.
Check whether a bitmap intersects the range [min, max).
Returns true if the bitmap is empty (cardinality is zero).
Return true if all the elements of r1 are also in r2, and r2 is strictly
greater than r1.
Return true if all the elements of r1 are also in r2.
Iterate over the bitmap elements. The function iterator
is called once for
all the values with ptr
(can be NULL) as the second parameter of each call.
Computes the Jaccard index between two bitmaps. (Also known as the Tanimoto
distance, or the Jaccard similarity coefficient)
Returns the largest value in the set, or 0 if empty.
Returns the smallest value in the set, or UINT64_MAX if the set is empty.
Creates a new bitmap of a pointer to N 64-bit integers.
Computes the union between two bitmaps and returns new bitmap. The caller is
responsible for free-ing the result.
Computes the size of the union between two bitmaps.
In-place version of roaring64_bitmap_or(), modifies
r1`.
Read a bitmap from a serialized buffer safely (reading up to maxbytes).
In case of failure, NULL is returned.
Check how many bytes would be read (up to maxbytes) at this pointer if there
is a valid bitmap, returns zero if there is no valid bitmap.
Write a bitmap to a buffer. The output buffer should refer to at least
roaring64_bitmap_portable_size_in_bytes(r)
bytes of allocated memory.
How many bytes are required to serialize this bitmap.
Returns the number of elements in the range [min, max).
Returns the number of integers that are smaller or equal to x. Thus if x is
the first element, this function will return 1. If x is smaller than the
smallest element, this function will return 0.
Removes a value from the bitmap if present.
Remove an item, using context from a previous insert for faster removal.
Removes a value from the bitmap if present, returns true if the value was
removed and false if the value was not present.
Remove n_args
values from vals
, faster than repeatedly calling
roaring64_bitmap_remove()
Remove all values in range [min, max).
Remove all values in range [min, max].
Returns true if the result has at least one run container.
Selects the element at index ‘rank’ where the smallest element is at index 0.
If the size of the bitmap is strictly greater than rank, then this function
returns true and sets element to the element of given rank. Otherwise, it
returns false.
Convert the bitmap to a sorted array out
.
Computes the symmetric difference (xor) between two bitmaps and returns a new
bitmap. The caller is responsible for free-ing the result.
Computes the size of the symmetric difference (xor) between two bitmaps.
In-place version of roaring64_bitmap_xor()
, modifies r1
. r1
and r2
are not allowed to be equal (that would result in an empty bitmap).
Advance the iterator. If there is a new value, then
roaring64_iterator_has_value()
returns true. Values are traversed in
increasing order. For convenience, returns the result of
roaring64_iterator_has_value()
.
Creates a copy of the iterator. Caller is responsible for calling
roaring64_iterator_free()
on the resulting iterator.
Create an iterator object that can be used to iterate through the values.
Caller is responsible for calling roaring64_iterator_free()
.
Create an iterator object that can be used to iterate through the values.
Caller is responsible for calling roaring64_iterator_free()
.
Free the iterator.
Returns true if the iterator currently points to a value. If so, calling
roaring64_iterator_value()
returns the value.
Move the iterator to the first value greater than or equal to val
, if it
exists at or after the current position of the iterator. If there is a new
value, then roaring64_iterator_has_value()
returns true. Values are
traversed in increasing order. For convenience, returns the result of
roaring64_iterator_has_value()
.
Decrement the iterator. If there is a new value, then
roaring64_iterator_has_value()
returns true. Values are traversed in
decreasing order. For convenience, returns the result of
roaring64_iterator_has_value()
.
Reads up to count
values from the iterator into the given buf
. Returns
the number of elements read. The number of elements read can be smaller than
count
, which means that there are no more elements in the bitmap.
Re-initializes an existing iterator. Functionally the same as
roaring64_iterator_create
without a allocation.
Re-initializes an existing iterator. Functionally the same as
roaring64_iterator_create_last
without a allocation.
Returns the value the iterator currently points to. Should only be called if
roaring64_iterator_has_value()
returns true.
Add value x
Add an item, using context from a previous insert for speed optimization.
Add value x
Returns true if a new value was added, false if the value already existed.
Add value n_args from pointer vals, faster than repeatedly calling
roaring_bitmap_add()
Add all values in range [min, max)
Add all values in range [min, max]
Computes the intersection between two bitmaps and returns new bitmap. The
caller is responsible for memory management.
Computes the size of the intersection between two bitmaps.
Inplace version of roaring_bitmap_and()
, modifies r1
r1 == r2 is allowed.
Computes the difference (andnot) between two bitmaps and returns new bitmap.
Caller is responsible for freeing the result.
Computes the size of the difference (andnot) between two bitmaps.
Inplace version of roaring_bitmap_andnot, modifies r1, r1 != r2.
Empties the bitmap. It will have no auxiliary allocations (so if the bitmap
was initialized in client memory via roaring_bitmap_init(), then a call to
roaring_bitmap_clear() would be enough to “free” it)
Check if value is present
Check if an items is present, using context from a previous insert or search
for speed optimization.
Check whether a range of values from range_start (included)
to range_end (excluded) is present
Copies a bitmap (this does memory allocation).
The caller is responsible for memory management.
Dynamically allocates a new bitmap (initially empty).
Returns NULL if the allocation fails.
Client is responsible for calling roaring_bitmap_free()
.
Dynamically allocates a new bitmap (initially empty).
Returns NULL if the allocation fails.
Capacity is a performance hint for how many “containers” the data will need.
Client is responsible for calling roaring_bitmap_free()
.
Use with roaring_bitmap_serialize()
.
Use with roaring_bitmap_serialize()
.
Return true if the two bitmaps contain the same elements.
Compute the negation of the bitmap in the interval [range_start, range_end).
The number of negated values is range_end - range_start.
Areas outside the range are passed through unchanged.
compute (in place) the negation of the roaring bitmap within a specified
interval: [range_start, range_end). The number of negated values is
range_end - range_start.
Areas outside the range are passed through unchanged.
Frees the memory.
Add all the values between min (included) and max (excluded) that are at a
distance k*step from min.
Serializes bitmap using frozen format.
Buffer size must be at least roaring_bitmap_frozen_size_in_bytes().
Returns number of bytes required to serialize bitmap using frozen format.
Creates constant bitmap that is a view of a given buffer.
Buffer data should have been written by roaring_bitmap_frozen_serialize()
Its beginning must also be aligned by 32 bytes.
Length must be equal exactly to roaring_bitmap_frozen_size_in_bytes()
.
In case of failure, NULL is returned.
Get the cardinality of the bitmap (number of elements).
Returns the index of x in the given roaring bitmap.
If the roaring bitmap doesn’t contain x , this function will return -1.
The difference with rank function is that this function will return -1 when x
is not the element of roaring bitmap, but the rank function will return a
non-negative number.
Initialize a roaring bitmap structure in memory controlled by client.
The bitmap will be in a “clear” state, with no auxiliary allocations.
Since this performs no allocations, the function will not fail.
Initialize a roaring bitmap structure in memory controlled by client.
Capacity is a performance hint for how many “containers” the data will need.
Can return false if auxiliary allocations fail when capacity greater than 0.
Perform internal consistency checks. Returns true if the bitmap is
consistent. It may be useful to call this after deserializing bitmaps from
untrusted sources. If roaring_bitmap_internal_validate returns true, then the
bitmap should be consistent and can be trusted not to cause crashes or memory
corruption.
Check whether two bitmaps intersect.
Check whether a bitmap and an open range intersect.
Returns true if the bitmap is empty (cardinality is zero).
Return true if all the elements of r1 are also in r2, and r2 is strictly
greater than r1.
Return true if all the elements of r1 are also in r2.
Computes the Jaccard index between two bitmaps. (Also known as the Tanimoto
distance, or the Jaccard similarity coefficient)
(For expert users who seek high performance.)
(For expert users who seek high performance.)
Computes the symmetric difference between two bitmaps and returns new bitmap.
The caller is responsible for memory management.
(For expert users who seek high performance.)
Returns the greatest value in the set, or 0 if the set is empty.
Returns the smallest value in the set, or UINT32_MAX if the set is empty.
Creates a new bitmap from a list of uint32_t integers
Creates a new bitmap from a pointer of uint32_t integers
Computes the union between two bitmaps and returns new bitmap. The caller is
responsible for memory management.
Computes the size of the union between two bitmaps.
Inplace version of `roaring_bitmap_or(), modifies r1.
TODO: decide whether r1 == r2 ok
Compute the union of ‘number’ bitmaps.
Caller is responsible for freeing the result.
See also roaring_bitmap_or_many_heap()
Compute the union of ‘number’ bitmaps using a heap. This can sometimes be
faster than `roaring_bitmap_or_many() which uses a naive algorithm.
Caller is responsible for freeing the result.
Copies a bitmap from src to dest. It is assumed that the pointer dest
is to an already allocated bitmap. The content of the dest bitmap is
freed/deleted.
Read bitmap from a serialized buffer.
In case of failure, NULL is returned.
Read bitmap from a serialized buffer.
In case of failure, NULL is returned.
Read bitmap from a serialized buffer safely (reading up to maxbytes).
In case of failure, NULL is returned.
Check how many bytes would be read (up to maxbytes) at this pointer if there
is a bitmap, returns zero if there is no valid bitmap.
Write a bitmap to a char buffer. The output buffer should refer to at least
roaring_bitmap_portable_size_in_bytes(r)
bytes of allocated memory.
How many bytes are required to serialize this bitmap.
Print the content of the bitmap.
Describe the inner structure of the bitmap.
Returns the number of elements in the range [range_start, range_end).
Convert the bitmap to a sorted array from offset
by limit
, output in
ans
.
roaring_bitmap_rank returns the number of integers that are smaller or equal
to x. Thus if x is the first element, this function will return 1. If
x is smaller than the smallest element, this function will return 0.
roaring_bitmap_rank_many is an Bulk
version of roaring_bitmap_rank
it puts rank value of each element in [begin .. end)
to ans[]
Remove value x
Remove value x
Returns true if a new value was removed, false if the value was not existing.
Remove multiple values
Remove all values in range [min, max)
Remove all values in range [min, max]
Remove run-length encoding even when it is more space efficient.
Return whether a change was applied.
(For expert users who seek high performance.)
Convert array and bitmap containers to run containers when it is more
efficient; also convert from run containers when more space efficient.
Selects the element at index ‘rank’ where the smallest element is at index 0.
If the size of the roaring bitmap is strictly greater than rank, then this
function returns true and sets element to the element of given rank.
Otherwise, it returns false.
Write the bitmap to an output pointer, this output buffer should refer to
at least roaring_bitmap_size_in_bytes(r)
allocated bytes.
If needed, reallocate memory to shrink the memory usage.
Returns the number of bytes saved.
How many bytes are required to serialize this bitmap (NOT compatible
with Java and Go versions)
(For advanced users.)
Store the bitmap to a bitset. This can be useful for people
who need the performance and simplicity of a standard bitset.
We assume that the input bitset is originally empty (does not
have any set bit).
Convert the bitmap to a sorted array, output in ans
.
Computes the symmetric difference (xor) between two bitmaps
and returns new bitmap. The caller is responsible for memory management.
Computes the size of the symmetric difference (xor) between two bitmaps.
Inplace version of roaring_bitmap_xor, modifies r1, r1 != r2.
Compute the xor of ‘number’ bitmaps.
Caller is responsible for freeing the result.
Iterate over the bitmap elements. The function iterator is called once for
all the values with ptr (can be NULL) as the second parameter of each call.
Create an iterator object that can be used to iterate through the values.
Caller is responsible for calling roaring_free_iterator()
.
Initialize an iterator object that can be used to iterate through the values.
If there is a value, then this iterator points to the first value and
it->has_value
is true. The value is in it->current_value
.
Initialize an iterator object that can be used to iterate through the values.
If there is a value, then this iterator points to the last value and
it->has_value
is true. The value is in it->current_value
.
result might be undefined when input_num is zero
result might be undefined when input_num is zero
Advance the iterator. If there is a new value, then it->has_value
is true.
The new value is in it->current_value
. Values are traversed in increasing
orders. For convenience, returns it->has_value
.
Creates a copy of an iterator.
Caller must free it.
Free memory following roaring_iterator_create()
Move the iterator to the first value >= val
. If there is a such a value,
then it->has_value
is true. The new value is in it->current_value
.
For convenience, returns it->has_value
.
Decrement the iterator. If there’s a new value, then it->has_value
is true.
The new value is in it->current_value
. Values are traversed in decreasing
order. For convenience, returns it->has_value
.