ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
RoaringBitmap.h

The compressed bitmap of Chambi, Lemire, Kaser and Godin (Roaring), beyond the book. More...

Files

file  ADS/set/RoaringBitmap.h
 The compressed bitmap of Chambi, Lemire, Kaser and Godin (Roaring), beyond the book: a SET of integers of 32 bits [see ADT.h], the engineered counterpart of the boolean vector of section 8.1 [see BoolSet.h] for universes too large for a bit per integer and sets too dense for a sorted list [see VectorIntersection.h].

Classes

class  ADS::RoaringBitmap
 a set of integers of 32 bits as a Roaring bitmap More...

Functions

RoaringBitmap ADS::setUnion (const RoaringBitmap &A, const RoaringBitmap &B)
 the union, by the merge of the containers
RoaringBitmap ADS::setIntersection (const RoaringBitmap &A, const RoaringBitmap &B)
 the intersection, by the merge of the containers
RoaringBitmap ADS::setDifference (const RoaringBitmap &A, const RoaringBitmap &B)
 the difference, by the merge of the containers
RoaringBitmap ADS::setSymmetricDifference (const RoaringBitmap &A, const RoaringBitmap &B)
 the symmetric difference, by the merge of the containers

Detailed description

The compressed bitmap of Chambi, Lemire, Kaser and Godin (Roaring), beyond the book.

The definitions, the invariants and the costs of the area are in Theory of sets.

Function documentation

◆ setDifference()

RoaringBitmap ADS::setDifference ( const RoaringBitmap & A,
const RoaringBitmap & B )

the difference, by the merge of the containers

In pseudocode (Chambi et al.), the containers merged by their chunks:

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{setDifference}( A , B ) \cr 2 & \quad C \gets \text{an empty set} \cr 3 & \quad \textbf{foreach}\ \text{chunk } k \text{ of } A \text{ or } B \text{, in increasing order}\ \textbf{do} \cr 4 & \qquad \textbf{if}\ \text{both have } k\ \textbf{then}\ X \gets \text{the difference of their two containers} \cr 5 & \qquad \textbf{else}\ X \gets \text{a copy of the container of } A \text{, if it has it} \cr 6 & \qquad \textbf{if}\ X \text{ is not empty }\ \textbf{then} \ \text{append } X \text{ to } C \cr 7 & \quad \textbf{return}\ C \end{array}} \]

◆ setIntersection()

RoaringBitmap ADS::setIntersection ( const RoaringBitmap & A,
const RoaringBitmap & B )

the intersection, by the merge of the containers

In pseudocode (Chambi et al.), the containers merged by their chunks:

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{setIntersection}( A , B ) \cr 2 & \quad C \gets \text{an empty set} \cr 3 & \quad \textbf{foreach}\ \text{chunk } k \text{ of } A \text{ or } B \text{, in increasing order}\ \textbf{do} \cr 4 & \qquad \textbf{if}\ \text{both have } k\ \textbf{then}\ X \gets \text{the intersection of their two containers} \cr 5 & \qquad \textbf{else}\ X \gets \text{nothing} \cr 6 & \qquad \textbf{if}\ X \text{ is not empty }\ \textbf{then} \ \text{append } X \text{ to } C \cr 7 & \quad \textbf{return}\ C \end{array}} \]

◆ setSymmetricDifference()

RoaringBitmap ADS::setSymmetricDifference ( const RoaringBitmap & A,
const RoaringBitmap & B )

the symmetric difference, by the merge of the containers

In pseudocode (Chambi et al.), the containers merged by their chunks:

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{setSymmetricDifference}( A , B ) \cr 2 & \quad C \gets \text{an empty set} \cr 3 & \quad \textbf{foreach}\ \text{chunk } k \text{ of } A \text{ or } B \text{, in increasing order}\ \textbf{do} \cr 4 & \qquad \textbf{if}\ \text{both have } k\ \textbf{then}\ X \gets \text{the symmetric difference of their two containers} \cr 5 & \qquad \textbf{else}\ X \gets \text{a copy of the container of the } \text{one that has it} \cr 6 & \qquad \textbf{if}\ X \text{ is not empty }\ \textbf{then} \ \text{append } X \text{ to } C \cr 7 & \quad \textbf{return}\ C \end{array}} \]

◆ setUnion()

RoaringBitmap ADS::setUnion ( const RoaringBitmap & A,
const RoaringBitmap & B )

the union, by the merge of the containers

In pseudocode (Chambi et al.), the containers merged by their chunks:

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{setUnion}( A , B ) \cr 2 & \quad C \gets \text{an empty set} \cr 3 & \quad \textbf{foreach}\ \text{chunk } k \text{ of } A \text{ or } B \text{, in increasing order}\ \textbf{do} \cr 4 & \qquad \textbf{if}\ \text{both have } k\ \textbf{then}\ X \gets \text{the union of their two containers} \cr 5 & \qquad \textbf{else}\ X \gets \text{a copy of the container of the } \text{one that has it} \cr 6 & \qquad \textbf{if}\ X \text{ is not empty }\ \textbf{then} \ \text{append } X \text{ to } C \cr 7 & \quad \textbf{return}\ C \end{array}} \]