CRoaring 4.3.5
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 42 of file roaring64map.hh.
Definition at line 1568 of file roaring64map.hh.
Definition at line 1566 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 54 of file roaring64map.hh.
References addMany().
|
inline |
Construct a bitmap from a list of 64-bit integer values.
Definition at line 59 of file roaring64map.hh.
References addMany().
|
inline |
Construct a bitmap from an initializer list.
Definition at line 64 of file roaring64map.hh.
References addMany().
|
inlineexplicit |
Construct a 64-bit map from a 32-bit one
Definition at line 71 of file roaring64map.hh.
|
inlineexplicit |
Construct a 64-bit map from a 32-bit rvalue
Definition at line 76 of file roaring64map.hh.
|
inlineexplicit |
Construct a roaring object from the C struct.
Passing a NULL point is unsafe.
Definition at line 83 of file roaring64map.hh.
|
default |
|
defaultnoexcept |
|
inline |
Adds value x.
Definition at line 137 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 149 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 156 of file roaring64map.hh.
References roaring::Roaring::addChecked().
|
inline |
Adds 'n_args' values from the contiguous memory range starting at 'vals'.
Definition at line 244 of file roaring64map.hh.
References roaring::Roaring::addMany().
Referenced by bitmapOfList(), Roaring64Map(), Roaring64Map(), and Roaring64Map().
|
inline |
Adds 'n_args' values from the contiguous memory range starting at 'vals'.
Definition at line 251 of file roaring64map.hh.
References roaring::Roaring::addBulk().
|
inline |
Adds all values in the half-open interval [min, max).
Definition at line 163 of file roaring64map.hh.
References addRangeClosed().
|
inline |
Adds all values in the closed interval [min, max].
Definition at line 173 of file roaring64map.hh.
References roaring::Roaring::addRangeClosed().
Referenced by addRange().
|
inline |
Adds all values in the closed interval [min, max]
Definition at line 180 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 1881 of file roaring64map.hh.
References Roaring64MapSetBitBiDirectionalIterator.
|
inlinestatic |
Construct a bitmap from a list of uint64_t values.
Definition at line 113 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 128 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 750 of file roaring64map.hh.
References isFull(), and ROARING_TERMINATE.
Referenced by isStrictSubset().
|
inline |
|
inline |
Check if value x is present
Definition at line 482 of file roaring64map.hh.
|
inline |
Definition at line 489 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 1885 of file roaring64map.hh.
References Roaring64MapSetBitBiDirectionalIterator.
Referenced by rank().
|
inlinestatic |
Computes the logical or (union) between "n" bitmaps (referenced by a pointer).
Definition at line 1442 of file roaring64map.hh.
References clear(), 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 901 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 912 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 933 of file roaring64map.hh.
|
inlinestatic |
Definition at line 1252 of file roaring64map.hh.
References roaring::Roaring::frozenView(), and read().
|
inline |
Whether or not copy and write is active.
Definition at line 1436 of file roaring64map.hh.
|
inline |
Definition at line 1345 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 1115 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 1239 of file roaring64map.hh.
|
inline |
Returns true if the bitmap is empty (cardinality is zero).
Definition at line 773 of file roaring64map.hh.
|
inline |
Returns true if the bitmap is full (cardinality is max uint64_t + 1).
Definition at line 784 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 830 of file roaring64map.hh.
References cardinality(), and isSubset().
|
inline |
Returns true if the bitmap is subset of the other.
Definition at line 810 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 1049 of file roaring64map.hh.
References roaring_iterate64().
|
inline |
Return the largest value (if not empty)
Definition at line 450 of file roaring64map.hh.
|
inline |
Return the smallest value (if not empty)
Definition at line 466 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 1373 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 507 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 1381 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 564 of file roaring64map.hh.
|
default |
Copy assignment operator.
|
defaultnoexcept |
Move assignment operator.
|
inline |
Assignment from an initializer list.
Definition at line 104 of file roaring64map.hh.
References Roaring64Map().
|
inline |
Return true if the two bitmaps contain the same elements.
Definition at line 855 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 1397 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 684 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 1389 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 632 of file roaring64map.hh.
|
inlinestatic |
Definition at line 1287 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 1417 of file roaring64map.hh.
|
inline |
Returns the number of integers that are smaller or equal to x.
Definition at line 1092 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 1173 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 1202 of file roaring64map.hh.
References roaring::Roaring::getSizeInBytes(), roaring::Roaring::readSafe(), and ROARING_TERMINATE.
|
inline |
Removes value x.
Definition at line 273 of file roaring64map.hh.
|
inline |
Removes value x.
Definition at line 288 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 303 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 323 of file roaring64map.hh.
|
inline |
Removes all values in the half-open interval [min, max).
Definition at line 339 of file roaring64map.hh.
References removeRangeClosed().
|
inline |
Removes all values in the closed interval [min, max].
Definition at line 349 of file roaring64map.hh.
Referenced by removeRange().
|
inline |
Removes all values in the closed interval [min, max].
Definition at line 365 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 996 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 1010 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 1066 of file roaring64map.hh.
References rank(), and ROARING_TERMINATE.
|
inline |
Whether or not we apply copy and write.
Definition at line 1404 of file roaring64map.hh.
|
inline |
If needed, reallocate memory to shrink the memory usage. Returns the number of bytes saved.
Definition at line 1022 of file roaring64map.hh.
|
inline |
Exchange the content of this bitmap with another.
Definition at line 742 of file roaring64map.hh.
|
inline |
Print the contents of the bitmap into a string.
Definition at line 1426 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 840 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 1140 of file roaring64map.hh.
|
inline |
Definition at line 1316 of file roaring64map.hh.
|
friend |
Definition at line 1565 of file roaring64map.hh.