Sparse bit vector that stores only elements containing set bits.
Synopsis
Declared in <llvm/ADT/SparseBitVector.h>
template<unsigned int ElementSize = 128>
class SparseBitVector;
Description
SparseBitVector is an implementation of a bitvector that is sparse by only storing the elements that have non‐zero bits set. In order to make this fast for the most common cases, SparseBitVector is implemented as a linked list of SparseBitVectorElements. We maintain a pointer to the last SparseBitVectorElement accessed (in the form of a list iterator), in order to make multiple in‐order test/set constant time after the first one is executed. Note that using vectors to store SparseBitVectorElement's does not work out very well because it causes insertion in the middle to take enormous amounts of time with a large amount of bits. Other structures that have better worst cases for insertion in the middle (various balanced trees, etc) do not perform as well in practice as a linked list with this iterator kept up to date. They are also significantly more memory intensive.
Type Aliases
Name |
Description |
Forward iterator yielding the indices of set bits in ascending order. |
Member Functions
Name |
Description |
|
Constructors |
Assignment operators |
|
Return an iterator to the first set bit, or end() if none are set. |
|
Remove all elements, leaving this vector empty. |
|
Return true if every bit set in |
|
Return the total number of bits set across all elements. |
|
Return true if this vector stores no elements (no bits are set). |
|
Return a past‐the‐end iterator for the set‐bits range. |
|
Return the index of the first set bit, or ‐1 if none are set. |
|
Return the index of the last set bit, or ‐1 if none are set. |
|
|
|
|
|
Intersect this vector with |
|
Union this vector with |
|
Clear bit |
|
Set bit |
|
Return true if bit |
|
Set bit |
|
Return true if this vector has the same set bits as |
|
Return true if this vector's set of bits differs from |
Non-Member Functions
Name |
Description |
Write the set‐bit indices of |
|
Return a sparse bit vector that is the intersection of |
|
Intersect |
|
Intersect |
|
Return a sparse bit vector with bits of |
|
Return a sparse bit vector that is the union of |
|
Union |
|
Union |
Created with MrDocs