CRoaring  3.0.0
Roaring bitmaps in C (and C++)
roaring::Roaring Class Reference

#include <roaring.hh>

Public Types

typedef RoaringSetBitForwardIterator const_iterator
 

Public Member Functions

 Roaring ()
 
 Roaring (size_t n, const uint32_t *data)
 
 Roaring (std::initializer_list< uint32_t > l)
 
 Roaring (const Roaring &r)
 
 Roaring (Roaring &&r) noexcept
 
 Roaring (roaring_bitmap_t *s) noexcept
 
void add (uint32_t x) noexcept
 
bool addChecked (uint32_t x) noexcept
 
void addRange (const uint64_t min, const uint64_t max) noexcept
 
void addRangeClosed (const uint32_t min, const uint32_t max) noexcept
 
void addMany (size_t n_args, const uint32_t *vals) noexcept
 
void addBulk (BulkContext &context, uint32_t x) noexcept
 
bool containsBulk (BulkContext &context, uint32_t x) const noexcept
 
void remove (uint32_t x) noexcept
 
bool removeChecked (uint32_t x) noexcept
 
void removeRange (uint64_t min, uint64_t max) noexcept
 
void removeRangeClosed (uint32_t min, uint32_t max) noexcept
 
uint32_t maximum () const noexcept
 
uint32_t minimum () const noexcept
 
bool contains (uint32_t x) const noexcept
 
bool containsRange (const uint64_t x, const uint64_t y) const noexcept
 
 ~Roaring ()
 
Roaringoperator= (const Roaring &r)
 
Roaringoperator= (Roaring &&r) noexcept
 
Roaringoperator= (std::initializer_list< uint32_t > l)
 
Roaringoperator&= (const Roaring &r) noexcept
 
Roaringoperator-= (const Roaring &r) noexcept
 
Roaringoperator|= (const Roaring &r) noexcept
 
Roaringoperator^= (const Roaring &r) noexcept
 
void swap (Roaring &r) noexcept
 
uint64_t cardinality () const noexcept
 
bool isEmpty () const noexcept
 
bool isSubset (const Roaring &r) const noexcept
 
bool isStrictSubset (const Roaring &r) const noexcept
 
void toUint32Array (uint32_t *ans) const noexcept
 
void rangeUint32Array (uint32_t *ans, size_t offset, size_t limit) const noexcept
 
bool operator== (const Roaring &r) const noexcept
 
void flip (uint64_t range_start, uint64_t range_end) noexcept
 
void flipClosed (uint32_t range_start, uint32_t range_end) noexcept
 
bool removeRunCompression () noexcept
 
bool runOptimize () noexcept
 
size_t shrinkToFit () noexcept
 
void iterate (api::roaring_iterator iterator, void *ptr) const
 
bool select (uint32_t rnk, uint32_t *element) const noexcept
 
uint64_t and_cardinality (const Roaring &r) const noexcept
 
bool intersect (const Roaring &r) const noexcept
 
double jaccard_index (const Roaring &r) const noexcept
 
uint64_t or_cardinality (const Roaring &r) const noexcept
 
uint64_t andnot_cardinality (const Roaring &r) const noexcept
 
uint64_t xor_cardinality (const Roaring &r) const noexcept
 
uint64_t rank (uint32_t x) const noexcept
 
void rank_many (const uint32_t *begin, const uint32_t *end, uint64_t *ans) const noexcept
 
int64_t getIndex (uint32_t x) const noexcept
 
size_t write (char *buf, bool portable=true) const noexcept
 
size_t getSizeInBytes (bool portable=true) const noexcept
 
void writeFrozen (char *buf) const noexcept
 
size_t getFrozenSizeInBytes () const noexcept
 
Roaring operator& (const Roaring &o) const
 
Roaring operator- (const Roaring &o) const
 
Roaring operator| (const Roaring &o) const
 
Roaring operator^ (const Roaring &o) const
 
void setCopyOnWrite (bool val) noexcept
 
void printf () const noexcept
 
std::string toString () const noexcept
 
bool getCopyOnWrite () const noexcept
 
const_iterator begin () const
 
const_iteratorend () const
 

Static Public Member Functions

static Roaring bitmapOf (size_t n,...)
 
static Roaring bitmapOfList (std::initializer_list< uint32_t > l)
 
static Roaring read (const char *buf, bool portable=true)
 
static Roaring readSafe (const char *buf, size_t maxbytes)
 
static const Roaring frozenView (const char *buf, size_t length)
 
static const Roaring portableDeserializeFrozen (const char *buf)
 
static Roaring fastunion (size_t n, const Roaring **inputs)
 

Public Attributes

roaring_bitmap_t roaring
 

Detailed Description

Definition at line 66 of file roaring.hh.

Member Typedef Documentation

◆ const_iterator

Constructor & Destructor Documentation

◆ Roaring() [1/6]

roaring::Roaring::Roaring ( )
inline

Create an empty bitmap in the existing memory for the class. The bitmap will be in the "clear" state with no auxiliary allocations.

Definition at line 74 of file roaring.hh.

◆ Roaring() [2/6]

roaring::Roaring::Roaring ( size_t  n,
const uint32_t *  data 
)
inline

Construct a bitmap from a list of 32-bit integer values.

Definition at line 83 of file roaring.hh.

◆ Roaring() [3/6]

roaring::Roaring::Roaring ( std::initializer_list< uint32_t >  l)
inline

Construct a bitmap from an initializer list.

Definition at line 90 of file roaring.hh.

◆ Roaring() [4/6]

roaring::Roaring::Roaring ( const Roaring r)
inline

Copy constructor. It may throw std::runtime_error if there is insufficient memory.

Definition at line 98 of file roaring.hh.

References roaring, and ROARING_TERMINATE.

◆ Roaring() [5/6]

roaring::Roaring::Roaring ( Roaring &&  r)
inlinenoexcept

Move constructor. The moved-from object remains valid but empty, i.e. it behaves as though it was just freshly constructed.

Definition at line 110 of file roaring.hh.

◆ Roaring() [6/6]

roaring::Roaring::Roaring ( roaring_bitmap_t *  s)
inlineexplicitnoexcept

Construct a roaring object by taking control of a malloc()'d C struct.

Passing a NULL pointer is unsafe. The pointer to the C struct will be invalid after the call.

Definition at line 127 of file roaring.hh.

◆ ~Roaring()

roaring::Roaring::~Roaring ( )
inline

Destructor. By contract, calling roaring_bitmap_clear() is enough to release all auxiliary memory used by the structure.

Definition at line 277 of file roaring.hh.

Member Function Documentation

◆ add()

void roaring::Roaring::add ( uint32_t  x)
inlinenoexcept

Add value x

Definition at line 158 of file roaring.hh.

Referenced by roaring::Roaring64Map::add(), and bitmapOf().

◆ addBulk()

void roaring::Roaring::addBulk ( BulkContext context,
uint32_t  x 
)
inlinenoexcept

Add value val, using context from a previous insert for speed optimization.

context will be used to store information between calls to make bulk operations faster. context should be default-initialized before the first call to this function.

Definition at line 198 of file roaring.hh.

Referenced by roaring::Roaring64Map::addMany().

◆ addChecked()

bool roaring::Roaring::addChecked ( uint32_t  x)
inlinenoexcept

Add value x Returns true if a new value was added, false if the value was already existing.

Definition at line 165 of file roaring.hh.

Referenced by roaring::Roaring64Map::addChecked().

◆ addMany()

void roaring::Roaring::addMany ( size_t  n_args,
const uint32_t *  vals 
)
inlinenoexcept

Add value n_args from pointer vals

Definition at line 186 of file roaring.hh.

Referenced by roaring::Roaring64Map::addMany(), and bitmapOfList().

◆ addRange()

void roaring::Roaring::addRange ( const uint64_t  min,
const uint64_t  max 
)
inlinenoexcept

Add all values in range [min, max)

Definition at line 172 of file roaring.hh.

◆ addRangeClosed()

void roaring::Roaring::addRangeClosed ( const uint32_t  min,
const uint32_t  max 
)
inlinenoexcept

Add all values in range [min, max]

Definition at line 179 of file roaring.hh.

Referenced by roaring::Roaring64Map::addRangeClosed().

◆ and_cardinality()

uint64_t roaring::Roaring::and_cardinality ( const Roaring r) const
inlinenoexcept

Computes the size of the intersection between two bitmaps.

Definition at line 504 of file roaring.hh.

◆ andnot_cardinality()

uint64_t roaring::Roaring::andnot_cardinality ( const Roaring r) const
inlinenoexcept

Computes the size of the difference (andnot) between two bitmaps.

Definition at line 536 of file roaring.hh.

◆ begin()

RoaringSetBitForwardIterator roaring::Roaring::begin ( ) const
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 988 of file roaring.hh.

◆ bitmapOf()

static Roaring roaring::Roaring::bitmapOf ( size_t  n,
  ... 
)
inlinestatic

Construct a bitmap from a list of uint32_t values.

Definition at line 134 of file roaring.hh.

References add().

◆ bitmapOfList()

static Roaring roaring::Roaring::bitmapOfList ( std::initializer_list< uint32_t >  l)
inlinestatic

Construct a bitmap from a list of uint32_t values. E.g., bitmapOfList({1,2,3}).

Definition at line 149 of file roaring.hh.

References addMany().

◆ cardinality()

uint64_t roaring::Roaring::cardinality ( ) const
inlinenoexcept

Get the cardinality of the bitmap (number of elements).

Definition at line 385 of file roaring.hh.

◆ contains()

bool roaring::Roaring::contains ( uint32_t  x) const
inlinenoexcept

Check if value x is present

Definition at line 262 of file roaring.hh.

◆ containsBulk()

bool roaring::Roaring::containsBulk ( BulkContext context,
uint32_t  x 
) const
inlinenoexcept

Check if item x is present, using context from a previous insert or search for speed optimization.

context will be used to store information between calls to make bulk operations faster. context should be default-initialized before the first call to this function.

Definition at line 210 of file roaring.hh.

◆ containsRange()

bool roaring::Roaring::containsRange ( const uint64_t  x,
const uint64_t  y 
) const
inlinenoexcept

Check if all values from x (included) to y (excluded) are present

Definition at line 269 of file roaring.hh.

◆ end()

RoaringSetBitForwardIterator & roaring::Roaring::end ( ) const
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 992 of file roaring.hh.

◆ fastunion()

static Roaring roaring::Roaring::fastunion ( size_t  n,
const Roaring **  inputs 
)
inlinestatic

Computes the logical or (union) between "n" bitmaps (referenced by a pointer). This function may throw std::runtime_error.

Definition at line 853 of file roaring.hh.

References ROARING_TERMINATE.

◆ flip()

void roaring::Roaring::flip ( uint64_t  range_start,
uint64_t  range_end 
)
inlinenoexcept

Compute the negation of the roaring bitmap within the half-open interval [range_start, range_end). Areas outside the interval are unchanged.

Definition at line 437 of file roaring.hh.

◆ flipClosed()

void roaring::Roaring::flipClosed ( uint32_t  range_start,
uint32_t  range_end 
)
inlinenoexcept

Compute the negation of the roaring bitmap within the closed interval [range_start, range_end]. Areas outside the interval are unchanged.

Definition at line 445 of file roaring.hh.

◆ frozenView()

static const Roaring roaring::Roaring::frozenView ( const char *  buf,
size_t  length 
)
inlinestatic

For advanced users. This function may throw std::runtime_error.

Definition at line 706 of file roaring.hh.

References roaring, and ROARING_TERMINATE.

Referenced by roaring::Roaring64Map::frozenView().

◆ getCopyOnWrite()

bool roaring::Roaring::getCopyOnWrite ( ) const
inlinenoexcept

Whether or not copy and write is active.

Definition at line 844 of file roaring.hh.

◆ getFrozenSizeInBytes()

size_t roaring::Roaring::getFrozenSizeInBytes ( ) const
inlinenoexcept

For advanced users.

Definition at line 742 of file roaring.hh.

◆ getIndex()

int64_t roaring::Roaring::getIndex ( uint32_t  x) const
inlinenoexcept

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 577 of file roaring.hh.

◆ getSizeInBytes()

size_t roaring::Roaring::getSizeInBytes ( bool  portable = true) const
inlinenoexcept

How many bytes are 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 694 of file roaring.hh.

Referenced by roaring::Roaring64Map::portableDeserializeFrozen(), roaring::Roaring64Map::read(), and roaring::Roaring64Map::readSafe().

◆ intersect()

bool roaring::Roaring::intersect ( const Roaring r) const
inlinenoexcept

Check whether the two bitmaps intersect.

Definition at line 511 of file roaring.hh.

◆ isEmpty()

bool roaring::Roaring::isEmpty ( ) const
inlinenoexcept

Returns true if the bitmap is empty (cardinality is zero).

Definition at line 392 of file roaring.hh.

◆ isStrictSubset()

bool roaring::Roaring::isStrictSubset ( const Roaring r) const
inlinenoexcept

Returns true if the bitmap is strict subset of the other.

Definition at line 406 of file roaring.hh.

◆ isSubset()

bool roaring::Roaring::isSubset ( const Roaring r) const
inlinenoexcept

Returns true if the bitmap is subset of the other.

Definition at line 399 of file roaring.hh.

◆ iterate()

void roaring::Roaring::iterate ( api::roaring_iterator  iterator,
void *  ptr 
) const
inline

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.

roaring_iterator is simply a pointer to a function that returns bool (true means that the iteration should continue while false means that it should stop), and takes (uint32_t,void*) as inputs.

Definition at line 485 of file roaring.hh.

◆ jaccard_index()

double roaring::Roaring::jaccard_index ( const Roaring r) const
inlinenoexcept

Computes the Jaccard index between two bitmaps. (Also known as the Tanimoto distance, or the Jaccard similarity coefficient)

The Jaccard index is undefined if both bitmaps are empty.

Definition at line 522 of file roaring.hh.

◆ maximum()

uint32_t roaring::Roaring::maximum ( ) const
inlinenoexcept

Return the largest value (if not empty)

Definition at line 248 of file roaring.hh.

◆ minimum()

uint32_t roaring::Roaring::minimum ( ) const
inlinenoexcept

Return the smallest value (if not empty)

Definition at line 255 of file roaring.hh.

◆ operator&()

Roaring roaring::Roaring::operator& ( const Roaring o) const
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. This function may throw std::runtime_error.

Definition at line 756 of file roaring.hh.

References roaring::BulkContext::Roaring, roaring, and ROARING_TERMINATE.

◆ operator&=()

Roaring& roaring::Roaring::operator&= ( const Roaring r)
inlinenoexcept

Compute the intersection between 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 340 of file roaring.hh.

◆ operator-()

Roaring roaring::Roaring::operator- ( const Roaring o) const
inline

Computes the difference between two bitmaps and returns new bitmap. The current bitmap and the provided bitmap are unchanged. This function may throw std::runtime_error.

Definition at line 769 of file roaring.hh.

References roaring::BulkContext::Roaring, roaring, and ROARING_TERMINATE.

◆ operator-=()

Roaring& roaring::Roaring::operator-= ( const Roaring r)
inlinenoexcept

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 350 of file roaring.hh.

◆ operator=() [1/3]

Roaring& roaring::Roaring::operator= ( const Roaring r)
inline

Copies the content of the provided bitmap, and discard the current content. It may throw std::runtime_error if there is insufficient memory.

Definition at line 299 of file roaring.hh.

References roaring, and ROARING_TERMINATE.

◆ operator=() [2/3]

Roaring& roaring::Roaring::operator= ( Roaring &&  r)
inlinenoexcept

Moves the content of the provided bitmap, and discard the current content.

Definition at line 312 of file roaring.hh.

◆ operator=() [3/3]

Roaring& roaring::Roaring::operator= ( std::initializer_list< uint32_t >  l)
inline

Assignment from an initializer list.

Definition at line 326 of file roaring.hh.

References roaring::BulkContext::Roaring.

◆ operator==()

bool roaring::Roaring::operator== ( const Roaring r) const
inlinenoexcept

Return true if the two bitmaps contain the same elements.

Definition at line 429 of file roaring.hh.

◆ operator^()

Roaring roaring::Roaring::operator^ ( const Roaring o) const
inline

Computes the symmetric union between two bitmaps and returns new bitmap. The current bitmap and the provided bitmap are unchanged. This function may throw std::runtime_error.

Definition at line 795 of file roaring.hh.

References roaring::BulkContext::Roaring, roaring, and ROARING_TERMINATE.

◆ operator^=()

Roaring& roaring::Roaring::operator^= ( const Roaring r)
inlinenoexcept

Compute the symmetric union between the current bitmap and the provided bitmap, writing the result in the current bitmap. The provided bitmap is not modified.

Definition at line 372 of file roaring.hh.

◆ operator|()

Roaring roaring::Roaring::operator| ( const Roaring o) const
inline

Computes the union between two bitmaps and returns new bitmap. The current bitmap and the provided bitmap are unchanged. This function may throw std::runtime_error.

Definition at line 782 of file roaring.hh.

References roaring::BulkContext::Roaring, roaring, and ROARING_TERMINATE.

◆ operator|=()

Roaring& roaring::Roaring::operator|= ( const Roaring r)
inlinenoexcept

Compute the union between 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 362 of file roaring.hh.

◆ or_cardinality()

uint64_t roaring::Roaring::or_cardinality ( const Roaring r) const
inlinenoexcept

Computes the size of the union between two bitmaps.

Definition at line 529 of file roaring.hh.

◆ portableDeserializeFrozen()

static const Roaring roaring::Roaring::portableDeserializeFrozen ( const char *  buf)
inlinestatic

For advanced users; see roaring_bitmap_portable_deserialize_frozen. This function may throw std::runtime_error.

Definition at line 721 of file roaring.hh.

References roaring, and ROARING_TERMINATE.

Referenced by roaring::Roaring64Map::portableDeserializeFrozen().

◆ printf()

void roaring::Roaring::printf ( ) const
inlinenoexcept

Print the content of the bitmap

Definition at line 813 of file roaring.hh.

◆ rangeUint32Array()

void roaring::Roaring::rangeUint32Array ( uint32_t *  ans,
size_t  offset,
size_t  limit 
) const
inlinenoexcept

To int array with pagination

Definition at line 421 of file roaring.hh.

◆ rank()

uint64_t roaring::Roaring::rank ( uint32_t  x) const
inlinenoexcept

Returns the number of integers that are smaller or equal to x. Thus the rank of the smallest element is one. If x is smaller than the smallest element, this function will return 0. The rank and select functions differ in convention: this function returns 1 when ranking the smallest value, but the select function returns the smallest value when using index 0.

Definition at line 556 of file roaring.hh.

◆ rank_many()

void roaring::Roaring::rank_many ( const uint32_t *  begin,
const uint32_t *  end,
uint64_t *  ans 
) const
inlinenoexcept

Get rank() values in bulk. The values in [begin .. end) must be in Ascending order. possible implementation: for(auto* iter = begin; iter != end; ++iter) *(ans++) = rank(*iter);

Definition at line 565 of file roaring.hh.

◆ read()

static Roaring roaring::Roaring::read ( const char *  buf,
bool  portable = true 
)
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, many bytes could be read. See also readSafe.

The function may throw std::runtime_error if a bitmap could not be read. Not that even if it does not throw, the bitmap could still be unusable if the loaded data does not match the portable Roaring specification: you should ensure that the data you load come from a serialized bitmap.

Definition at line 644 of file roaring.hh.

References roaring::BulkContext::Roaring, and ROARING_TERMINATE.

Referenced by roaring::Roaring64Map::read().

◆ readSafe()

static Roaring roaring::Roaring::readSafe ( const char *  buf,
size_t  maxbytes 
)
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. The function itself is safe in the sense that it will not cause buffer overflows. However, for correct operations, it is assumed that the bitmap read was once serialized from a valid bitmap. If you provided an incorrect input (garbage), then the bitmap read may not be in a valid state and following operations may not lead to sensible results. It is your responsability to ensure that the input bytes follow the format specification if you want a usable bitmap: https://github.com/RoaringBitmap/RoaringFormatSpec In particular, the serialized array containers need to be in sorted order, and the run containers should be in sorted non-overlapping order. This is is guaranteed to happen when serializing an existing bitmap, but not for random inputs. Note that this function assumes that your bitmap was serialized in portable mode (which is the default with the 'write' method).

The function may throw std::runtime_error if a bitmap could not be read. Not that even if it does not throw, the bitmap could still be unusable if the loaded data does not match the portable Roaring specification: you should ensure that the data you load come from a serialized bitmap.

Definition at line 677 of file roaring.hh.

References roaring::BulkContext::Roaring, and ROARING_TERMINATE.

Referenced by roaring::Roaring64Map::readSafe().

◆ remove()

void roaring::Roaring::remove ( uint32_t  x)
inlinenoexcept

Remove value x

Definition at line 218 of file roaring.hh.

◆ removeChecked()

bool roaring::Roaring::removeChecked ( uint32_t  x)
inlinenoexcept

Remove value x Returns true if a new value was removed, false if the value was not existing.

Definition at line 227 of file roaring.hh.

◆ removeRange()

void roaring::Roaring::removeRange ( uint64_t  min,
uint64_t  max 
)
inlinenoexcept

Remove all values in range [min, max)

Definition at line 234 of file roaring.hh.

◆ removeRangeClosed()

void roaring::Roaring::removeRangeClosed ( uint32_t  min,
uint32_t  max 
)
inlinenoexcept

Remove all values in range [min, max]

Definition at line 241 of file roaring.hh.

◆ removeRunCompression()

bool roaring::Roaring::removeRunCompression ( )
inlinenoexcept

Remove run-length encoding even when it is more space efficient. Return whether a change was applied.

Definition at line 454 of file roaring.hh.

◆ runOptimize()

bool roaring::Roaring::runOptimize ( )
inlinenoexcept

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 464 of file roaring.hh.

◆ select()

bool roaring::Roaring::select ( uint32_t  rnk,
uint32_t *  element 
) const
inlinenoexcept

Selects the value at index rnk in the bitmap, where the smallest value 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.

Definition at line 497 of file roaring.hh.

◆ setCopyOnWrite()

void roaring::Roaring::setCopyOnWrite ( bool  val)
inlinenoexcept

Whether or not we apply copy and write.

Definition at line 806 of file roaring.hh.

◆ shrinkToFit()

size_t roaring::Roaring::shrinkToFit ( )
inlinenoexcept

If needed, reallocate memory to shrink the memory usage. Returns the number of bytes saved.

Definition at line 472 of file roaring.hh.

◆ swap()

void roaring::Roaring::swap ( Roaring r)
inlinenoexcept

Exchange the content of this bitmap with another.

Definition at line 380 of file roaring.hh.

◆ toString()

std::string roaring::Roaring::toString ( ) const
inlinenoexcept

Print the content of the bitmap into a string

Definition at line 818 of file roaring.hh.

◆ toUint32Array()

void roaring::Roaring::toUint32Array ( uint32_t *  ans) const
inlinenoexcept

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 415 of file roaring.hh.

◆ write()

size_t roaring::Roaring::write ( char *  buf,
bool  portable = true 
) const
inlinenoexcept

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 enable a custom format that can save space compared to the portable format (e.g., for very sparse bitmaps).

Boost users can serialize bitmaps in this manner:

  BOOST_SERIALIZATION_SPLIT_FREE(Roaring)
  namespace boost {
  namespace serialization {

  template <class Archive>
  void save(Archive& ar, const Roaring& bitmask,
     const unsigned int version) {
    std::size_t expected_size_in_bytes = bitmask.getSizeInBytes();
    std::vector<char> buffer(expected_size_in_bytes);
    std::size_t       size_in_bytes = bitmask.write(buffer.data());

    ar& size_in_bytes;
    ar& boost::serialization::make_binary_object(buffer.data(),
        size_in_bytes);
 }
 template <class Archive>
 void load(Archive& ar, Roaring& bitmask,
     const unsigned int version) {
    std::size_t size_in_bytes = 0;
    ar& size_in_bytes;
    std::vector<char> buffer(size_in_bytes);
    ar&  boost::serialization::make_binary_object(buffer.data(),
       size_in_bytes);
    bitmask = Roaring::readSafe(buffer.data(), size_in_bytes);
 }
 }  // namespace serialization
 }  // namespace boost

Definition at line 620 of file roaring.hh.

◆ writeFrozen()

void roaring::Roaring::writeFrozen ( char *  buf) const
inlinenoexcept

For advanced users.

Definition at line 735 of file roaring.hh.

◆ xor_cardinality()

uint64_t roaring::Roaring::xor_cardinality ( const Roaring r) const
inlinenoexcept

Computes the size of the symmetric difference (andnot) between two bitmaps.

Definition at line 544 of file roaring.hh.

Member Data Documentation

◆ roaring


The documentation for this class was generated from the following file: