CRoaring
4.2.1
Roaring bitmaps in C (and C++)
|
#include <roaring64map.hh>
Public Types | |
typedef Roaring64MapSetBitBiDirectionalIterator | const_iterator |
typedef Roaring64MapSetBitBiDirectionalIterator | const_bidirectional_iterator |
Public Member Functions | |
Roaring64Map ()=default | |
Roaring64Map (size_t n, const uint32_t *data) | |
Roaring64Map (size_t n, const uint64_t *data) | |
Roaring64Map (std::initializer_list< uint64_t > l) | |
Roaring64Map (const Roaring &r) | |
Roaring64Map (Roaring &&r) | |
Roaring64Map (roaring_bitmap_t *s) | |
Roaring64Map (const Roaring64Map &r)=default | |
Roaring64Map (Roaring64Map &&r) noexcept=default | |
Roaring64Map & | operator= (const Roaring64Map &r)=default |
Roaring64Map & | operator= (Roaring64Map &&r) noexcept=default |
Roaring64Map & | operator= (std::initializer_list< uint64_t > l) |
void | add (uint32_t x) |
void | add (uint64_t x) |
bool | addChecked (uint32_t x) |
bool | addChecked (uint64_t x) |
void | addRange (uint64_t min, uint64_t max) |
void | addRangeClosed (uint32_t min, uint32_t max) |
void | addRangeClosed (uint64_t min, uint64_t max) |
void | addMany (size_t n_args, const uint32_t *vals) |
void | addMany (size_t n_args, const uint64_t *vals) |
void | remove (uint32_t x) |
void | remove (uint64_t x) |
bool | removeChecked (uint32_t x) |
bool | removeChecked (uint64_t x) |
void | removeRange (uint64_t min, uint64_t max) |
void | removeRangeClosed (uint32_t min, uint32_t max) |
void | removeRangeClosed (uint64_t min, uint64_t max) |
void | clear () |
uint64_t | maximum () const |
uint64_t | minimum () const |
bool | contains (uint32_t x) const |
bool | contains (uint64_t x) const |
Roaring64Map & | operator&= (const Roaring64Map &other) |
Roaring64Map & | operator-= (const Roaring64Map &other) |
Roaring64Map & | operator|= (const Roaring64Map &other) |
Roaring64Map & | operator^= (const Roaring64Map &other) |
void | swap (Roaring64Map &r) |
uint64_t | cardinality () const |
bool | isEmpty () const |
bool | isFull () const |
bool | isSubset (const Roaring64Map &r) const |
bool | isStrictSubset (const Roaring64Map &r) const |
void | toUint64Array (uint64_t *ans) const |
bool | operator== (const Roaring64Map &r) const |
void | flip (uint64_t min, uint64_t max) |
void | flipClosed (uint32_t min, uint32_t max) |
void | flipClosed (uint64_t min, uint64_t max) |
bool | removeRunCompression () |
bool | runOptimize () |
size_t | shrinkToFit () |
void | iterate (api::roaring_iterator64 iterator, void *ptr) const |
bool | select (uint64_t rank, uint64_t *element) const |
uint64_t | rank (uint64_t x) const |
int64_t | getIndex (uint64_t x) const |
size_t | write (char *buf, bool portable=true) const |
size_t | getSizeInBytes (bool portable=true) const |
void | writeFrozen (char *buf) const |
size_t | getFrozenSizeInBytes () const |
Roaring64Map | operator& (const Roaring64Map &o) const |
Roaring64Map | operator- (const Roaring64Map &o) const |
Roaring64Map | operator| (const Roaring64Map &o) const |
Roaring64Map | operator^ (const Roaring64Map &o) const |
void | setCopyOnWrite (bool val) |
void | printf () const |
std::string | toString () const |
bool | getCopyOnWrite () const |
const_iterator | begin () const |
const_iterator | end () const |
Static Public Member Functions | |
static Roaring64Map | bitmapOf (size_t n...) |
static Roaring64Map | bitmapOfList (std::initializer_list< uint64_t > l) |
static Roaring64Map | read (const char *buf, bool portable=true) |
static Roaring64Map | readSafe (const char *buf, size_t maxbytes) |
static const Roaring64Map | frozenView (const char *buf) |
static const Roaring64Map | portableDeserializeFrozen (const char *buf) |
static Roaring64Map | fastunion (size_t n, const Roaring64Map **inputs) |
Friends | |
class | Roaring64MapSetBitBiDirectionalIterator |
Definition at line 41 of file roaring64map.hh.
Definition at line 1559 of file roaring64map.hh.
Definition at line 1557 of file roaring64map.hh.
|
default |
Create an empty bitmap
Referenced by operator&(), operator-(), operator=(), operator^(), and operator|().
|
inline |
Construct a bitmap from a list of 32-bit integer values.
Definition at line 53 of file roaring64map.hh.
References addMany().
|
inline |
Construct a bitmap from a list of 64-bit integer values.
Definition at line 58 of file roaring64map.hh.
References addMany().
|
inline |
Construct a bitmap from an initializer list.
Definition at line 63 of file roaring64map.hh.
References addMany().
|
inlineexplicit |
Construct a 64-bit map from a 32-bit one
Definition at line 70 of file roaring64map.hh.
|
inlineexplicit |
Construct a 64-bit map from a 32-bit rvalue
Definition at line 75 of file roaring64map.hh.
|
inlineexplicit |
Construct a roaring object from the C struct.
Passing a NULL point is unsafe.
Definition at line 82 of file roaring64map.hh.
|
default |
|
defaultnoexcept |
|
inline |
Adds value x.
Definition at line 136 of file roaring64map.hh.
References roaring::Roaring::add().
Referenced by bitmapOf().
|
inline |
|
inline |
Adds value x. Returns true if a new value was added, false if the value was already present.
Definition at line 148 of file roaring64map.hh.
References roaring::Roaring::addChecked().
|
inline |
Adds value x. Returns true if a new value was added, false if the value was already present.
Definition at line 155 of file roaring64map.hh.
References roaring::Roaring::addChecked().
|
inline |
Adds 'n_args' values from the contiguous memory range starting at 'vals'.
Definition at line 243 of file roaring64map.hh.
References roaring::Roaring::addMany().
Referenced by bitmapOfList(), and Roaring64Map().
|
inline |
Adds 'n_args' values from the contiguous memory range starting at 'vals'.
Definition at line 250 of file roaring64map.hh.
References roaring::Roaring::addBulk().
|
inline |
Adds all values in the half-open interval [min, max).
Definition at line 162 of file roaring64map.hh.
References addRangeClosed().
|
inline |
Adds all values in the closed interval [min, max].
Definition at line 172 of file roaring64map.hh.
References roaring::Roaring::addRangeClosed().
Referenced by addRange().
|
inline |
Adds all values in the closed interval [min, max]
Definition at line 179 of file roaring64map.hh.
|
inline |
Returns an iterator that can be used to access the position of the set bits. The running time complexity of a full scan is proportional to the number of set bits: be aware that if you have long strings of 1s, this can be very inefficient.
It can be much faster to use the toArray method if you want to retrieve the set bits.
Definition at line 1872 of file roaring64map.hh.
References Roaring64MapSetBitBiDirectionalIterator.
|
inlinestatic |
Construct a bitmap from a list of uint64_t values.
Definition at line 112 of file roaring64map.hh.
References add().
|
inlinestatic |
Construct a bitmap from a list of uint64_t values. E.g., bitmapOfList({1,2,3}).
Definition at line 127 of file roaring64map.hh.
References addMany().
|
inline |
Get the cardinality of the bitmap (number of elements). Throws std::length_error in the special case where the bitmap is full (cardinality() == 2^64). Check isFull() before calling to avoid exception.
Definition at line 749 of file roaring64map.hh.
References isFull(), and ROARING_TERMINATE.
Referenced by isStrictSubset().
|
inline |
|
inline |
Check if value x is present
Definition at line 481 of file roaring64map.hh.
|
inline |
Definition at line 488 of file roaring64map.hh.
|
inline |
A bogus iterator that can be used together with begin() for constructions such as: for (auto i = b.begin(); * i!=b.end(); ++i) {}
Definition at line 1876 of file roaring64map.hh.
References Roaring64MapSetBitBiDirectionalIterator.
Referenced by fastunion(), and rank().
|
inlinestatic |
Computes the logical or (union) between "n" bitmaps (referenced by a pointer).
Definition at line 1433 of file roaring64map.hh.
References clear(), end(), and roaring_bitmap_or_many().
|
inline |
Computes the negation of the roaring bitmap within the half-open interval [min, max). Areas outside the interval are unchanged.
Definition at line 892 of file roaring64map.hh.
References flipClosed().
|
inline |
Computes the negation of the roaring bitmap within the closed interval [min, max]. Areas outside the interval are unchanged.
Definition at line 903 of file roaring64map.hh.
Referenced by flip().
|
inline |
Computes the negation of the roaring bitmap within the closed interval [min, max]. Areas outside the interval are unchanged.
Definition at line 924 of file roaring64map.hh.
|
inlinestatic |
Definition at line 1243 of file roaring64map.hh.
References roaring::Roaring::frozenView(), and read().
|
inline |
Whether or not copy and write is active.
Definition at line 1427 of file roaring64map.hh.
|
inline |
Definition at line 1336 of file roaring64map.hh.
|
inline |
Returns the index of x in the set, index start from 0. If the set doesn't contain x , this function will return -1. The difference with rank function is that this function will return -1 when x isn't in the set, but the rank function will return a non-negative number.
Definition at line 1106 of file roaring64map.hh.
|
inline |
Return the number of bytes required to serialize this bitmap (meant to be compatible with Java and Go versions)
Setting the portable flag to false enable a custom format that can save space compared to the portable format (e.g., for very sparse bitmaps).
Definition at line 1230 of file roaring64map.hh.
|
inline |
Returns true if the bitmap is empty (cardinality is zero).
Definition at line 772 of file roaring64map.hh.
|
inline |
Returns true if the bitmap is full (cardinality is max uint64_t + 1).
Definition at line 783 of file roaring64map.hh.
Referenced by cardinality().
|
inline |
Returns true if the bitmap is strict subset of the other. Throws std::length_error in the special case where the bitmap is full (cardinality() == 2^64). Check isFull() before calling to avoid exception.
Definition at line 821 of file roaring64map.hh.
References cardinality(), and isSubset().
|
inline |
Returns true if the bitmap is subset of the other.
Definition at line 801 of file roaring64map.hh.
Referenced by isStrictSubset().
|
inline |
Iterate over the bitmap elements in order(start from the smallest one) and call iterator once for every element until the iterator function returns false. To iterate over all values, the iterator function should always return true.
The roaring_iterator64 parameter is a pointer to a function that returns bool (true means that the iteration should continue while false means that it should stop), and takes (uint64_t element, void* ptr) as inputs.
Definition at line 1040 of file roaring64map.hh.
References roaring_iterate64().
|
inline |
Return the largest value (if not empty)
Definition at line 449 of file roaring64map.hh.
|
inline |
Return the smallest value (if not empty)
Definition at line 465 of file roaring64map.hh.
|
inline |
Computes the intersection between two bitmaps and returns new bitmap. The current bitmap and the provided bitmap are unchanged.
Performance hint: if you are computing the intersection between several bitmaps, two-by-two, it is best to start with the smallest bitmap. Consider also using the operator &= to avoid needlessly creating many temporary bitmaps.
Definition at line 1364 of file roaring64map.hh.
References Roaring64Map().
|
inline |
Compute the intersection of the current bitmap and the provided bitmap, writing the result in the current bitmap. The provided bitmap is not modified.
Performance hint: if you are computing the intersection between several bitmaps, two-by-two, it is best to start with the smallest bitmap.
Definition at line 506 of file roaring64map.hh.
|
inline |
Computes the difference between two bitmaps and returns new bitmap. The current bitmap and the provided bitmap are unchanged.
Definition at line 1372 of file roaring64map.hh.
References Roaring64Map().
|
inline |
Compute the difference between the current bitmap and the provided bitmap, writing the result in the current bitmap. The provided bitmap is not modified.
Definition at line 563 of file roaring64map.hh.
|
default |
Copy assignment operator.
|
defaultnoexcept |
Move assignment operator.
|
inline |
Assignment from an initializer list.
Definition at line 103 of file roaring64map.hh.
References Roaring64Map().
|
inline |
Return true if the two bitmaps contain the same elements.
Definition at line 846 of file roaring64map.hh.
|
inline |
Computes the symmetric union between two bitmaps and returns new bitmap. The current bitmap and the provided bitmap are unchanged.
Definition at line 1388 of file roaring64map.hh.
References Roaring64Map().
|
inline |
Compute the XOR of the current bitmap and the provided bitmap, writing the result in the current bitmap. The provided bitmap is not modified.
Definition at line 683 of file roaring64map.hh.
|
inline |
Computes the union between two bitmaps and returns new bitmap. The current bitmap and the provided bitmap are unchanged.
Definition at line 1380 of file roaring64map.hh.
References Roaring64Map().
|
inline |
Compute the union of the current bitmap and the provided bitmap, writing the result in the current bitmap. The provided bitmap is not modified.
See also the fastunion function to aggregate many bitmaps more quickly.
Definition at line 631 of file roaring64map.hh.
|
inlinestatic |
Definition at line 1278 of file roaring64map.hh.
References roaring::Roaring::getSizeInBytes(), and roaring::Roaring::portableDeserializeFrozen().
|
inline |
Print the contents of the bitmap to stdout. Note: this method adds a final newline, but toString() does not.
Definition at line 1408 of file roaring64map.hh.
|
inline |
Returns the number of integers that are smaller or equal to x.
Definition at line 1083 of file roaring64map.hh.
References end().
Referenced by select().
|
inlinestatic |
Read a bitmap from a serialized version. This is meant to be compatible with the Java and Go versions.
Setting the portable flag to false enable a custom format that can save space compared to the portable format (e.g., for very sparse bitmaps).
This function is unsafe in the sense that if you provide bad data, many bytes could be read, possibly causing a buffer overflow. See also readSafe.
Definition at line 1164 of file roaring64map.hh.
References roaring::Roaring::getSizeInBytes(), and roaring::Roaring::read().
Referenced by frozenView().
|
inlinestatic |
Read a bitmap from a serialized version, reading no more than maxbytes bytes. This is meant to be compatible with the Java and Go versions.
Setting the portable flag to false enable a custom format that can save space compared to the portable format (e.g., for very sparse bitmaps).
Definition at line 1193 of file roaring64map.hh.
References roaring::Roaring::getSizeInBytes(), roaring::Roaring::readSafe(), and ROARING_TERMINATE.
|
inline |
Removes value x.
Definition at line 272 of file roaring64map.hh.
|
inline |
Removes value x.
Definition at line 287 of file roaring64map.hh.
|
inline |
Removes value x Returns true if a new value was removed, false if the value was not present.
Definition at line 302 of file roaring64map.hh.
|
inline |
Remove value x Returns true if a new value was removed, false if the value was not present.
Definition at line 322 of file roaring64map.hh.
|
inline |
Removes all values in the half-open interval [min, max).
Definition at line 338 of file roaring64map.hh.
References removeRangeClosed().
|
inline |
Removes all values in the closed interval [min, max].
Definition at line 348 of file roaring64map.hh.
Referenced by removeRange().
|
inline |
Removes all values in the closed interval [min, max].
Definition at line 364 of file roaring64map.hh.
|
inline |
Remove run-length encoding even when it is more space efficient return whether a change was applied
Definition at line 987 of file roaring64map.hh.
|
inline |
Convert array and bitmap containers to run containers when it is more efficient; also convert from run containers when more space efficient. Returns true if the result has at least one run container. Additional savings might be possible by calling shrinkToFit().
Definition at line 1001 of file roaring64map.hh.
|
inline |
Selects the value at index 'rank' in the bitmap, where the smallest value is at index 0. If 'rank' < cardinality(), returns true with *element set to the element of the specified rank. Otherwise, returns false and the contents of *element are unspecified.
Definition at line 1057 of file roaring64map.hh.
References rank(), and ROARING_TERMINATE.
|
inline |
Whether or not we apply copy and write.
Definition at line 1395 of file roaring64map.hh.
|
inline |
If needed, reallocate memory to shrink the memory usage. Returns the number of bytes saved.
Definition at line 1013 of file roaring64map.hh.
|
inline |
Exchange the content of this bitmap with another.
Definition at line 741 of file roaring64map.hh.
|
inline |
Print the contents of the bitmap into a string.
Definition at line 1417 of file roaring64map.hh.
|
inline |
Convert the bitmap to an array. Write the output to "ans", caller is responsible to ensure that there is enough memory allocated (e.g., ans = new uint32[mybitmap.cardinality()];)
Definition at line 831 of file roaring64map.hh.
|
inline |
Write a bitmap to a char buffer. This is meant to be compatible with the Java and Go versions. Returns how many bytes were written which should be getSizeInBytes().
Setting the portable flag to false enables a custom format that can save space compared to the portable format (e.g., for very sparse bitmaps).
Definition at line 1131 of file roaring64map.hh.
|
inline |
Definition at line 1307 of file roaring64map.hh.
|
friend |
Definition at line 1556 of file roaring64map.hh.