BLBitSet Class Referencefinal

BitSet container [C++ API].

BitSet container implements sparse BitSet that consists of segments, where each segment represents either dense range of bits or a range of bits that are all set to one. In addition, the BitSet provides also a SSO mode, in which it's possible to store up to 64 dense bits (2 consecutive BitWords) in the whole addressable range or a range of ones. SSO mode optimizes use cases, in which very small BitSets are needed.

The BitSet itself has been optimized for Blend2D use cases, which are the following:

  1. Representing character coverage of fonts and unicode text. This use-case requires sparseness and ranges as some fonts, especially those designed for CJK use, provide thousands of glyphs that have pretty high code points - using BLBitArray would be very wasteful in this particular case.

Member Functions

Construction & Destruction
Overloaded Operators
Common Functionality
Accessors
Test Operations
Equality & Comparison
Content Manipulation

Additional Inherited Members

- Public Attributes inherited from BLObjectCore

Constructor & Destructor Documentation

BLBitSet::~BLBitSet()◆ 

Destroys the BitSet.

Member Function Documentation

BLBitSet::operator bool() constexplicit◆ 

Tests whether the BitSet has a content.

Note
This is essentially the opposite of empty().

BLBitSet& BLBitSet::operator=(BLBitSet&& other)[1/2]◆ 

Move assignment.

Note
The other BitSet is reset by move assignment, so its state after the move operation is the same as a default constructed BitSet.

BLBitSet& BLBitSet::operator=(const BLBitSet& other)[2/2]◆ 

Copy assignment, performs weak copy of the data held by the other BitSet.

BLResult BLBitSet::reset()◆ 

Clears the content of the BitSet and releases its data.

After reset the BitSet content matches a default constructed instance.

void BLBitSet::swap(BLBitSetCore& other)◆ 

Swaps the content of this string with the other string.

bool BLBitSet::empty() const◆ 

Tests whether the BitSet is empty (has no content).

Returns true if the BitSet's size is zero.

uint32_t BLBitSet::segmentCount() const◆ 

Returns the number of segments this BitSet occupies.

Note
If the BitSet is in SSO mode then the returned value is the number of segments the BitSet would occupy when the BitSet was converted to dynamic.

uint32_t BLBitSet::segmentCapacity() const◆ 

Returns the number of segments this BitSet has allocated.

Note
If the BitSet is in SSO mode the returned value is always zero.

bool BLBitSet::getRange(uint32_t* startOut, uint32_t* endOut) const◆ 

Returns the range of the BitSet as [startOut, endOut).

Returns true if the query was successful, false if the BitSet is empty.

uint32_t BLBitSet::cardinality() const◆ 

Returns the number of bits set in the BitSet.

uint32_t BLBitSet::cardinalityInRange(uint32_t startBit, uint32_t endBit) const◆ 

Returns the number of bits set in the given [startBit, endBit) range.

BLResult BLBitSet::getData(BLBitSetData* out) const◆ 

Stores a normalized BitSet data represented as segments into out.

If the BitSet is in SSO mode, it will be converter to temporary segments provided by BLBitSetData::ssoSegments, if the BitSet is in dynamic mode (already contains segments) then only a pointer to the data will be stored into out.

Remarks
The data written into out can reference the data in the BitSet, thus the BitSet cannot be manipulated during the use of the data. This function is ideal for inspecting the content of the BitSet in a unique way and for implementing iterators that don't have to be aware of how SSO data is represented and used.

bool BLBitSet::hasBit(uint32_t bitIndex) const◆ 

Returns a bit-value at the given bitIndex.

bool BLBitSet::hasBitsInRange(uint32_t startBit, uint32_t endBit) const◆ 

Returns whether the bit-set has at least on bit in the given range [start:end).

bool BLBitSet::subsumes(const BLBitSetCore& other) const◆ 

Returns whether this BitSet subsumes other.

bool BLBitSet::intersects(const BLBitSetCore& other) const◆ 

Returns whether this BitSet intersects with other.

bool BLBitSet::equals(const BLBitSetCore& other) const◆ 

Returns whether this BitSet and other are bitwise equal.

int BLBitSet::compare(const BLBitSetCore& other) const◆ 

Compares this BitSet with other and returns either -1, 0, or 1.

BLResult BLBitSet::assign(BLBitSetCore&& other)[1/2]◆ 

Move assignment, the same as operator=, but returns a BLResult instead of this.

BLResult BLBitSet::assign(const BLBitSetCore& other)[2/2]◆ 

Copy assignment, the same as operator=, but returns a BLResult instead of this.

BLResult BLBitSet::assignDeep(const BLBitSetCore& other)◆ 

Copy assignment, but creates a deep copy of the other BitSet instead of weak copy.

BLResult BLBitSet::assignRange(uint32_t startBit, uint32_t endBit)◆ 

Replaces the content of the BitSet by the given range.

BLResult BLBitSet::assignWords(uint32_t startWord, const uint32_t* wordData, uint32_t wordCount)◆ 

Replaces the content of the BitSet by bits specified by wordData of size wordCount [the size is in uint32_t units].

BLResult BLBitSet::clear()◆ 

Clears the content of the BitSet without releasing its dynamically allocated data, if possible.

BLResult BLBitSet::shrink()◆ 

Shrinks the capacity of the BitSet to match the actual content.

BLResult BLBitSet::optimize()◆ 

Optimizes the BitSet by clearing unused pages and by merging continuous pages, without reallocating the BitSet. This functions should always return BL_SUCCESS.

BLResult BLBitSet::chop(uint32_t startBit, uint32_t endBit)◆ 

Bounds the BitSet to the given interval [start:end).

BLResult BLBitSet::truncate(uint32_t n)◆ 

Truncates the BitSet so it's maximum bit set is less than n.

BLResult BLBitSet::addBit(uint32_t bitIndex)◆ 

Adds a bit to the BitSet at the given index.

BLResult BLBitSet::addRange(uint32_t rangeStartBit, uint32_t rangeEndBit)◆ 

Adds a range of bits [rangeStartBit:rangeEndBit) to the BitSet.

BLResult BLBitSet::addWords(uint32_t startWord, const uint32_t* wordData, uint32_t wordCount)◆ 

Adds a dense data to the BitSet starting a bit index start.

BLResult BLBitSet::clearBit(uint32_t bitIndex)◆ 

Clears a bit in the BitSet at the given index.

BLResult BLBitSet::clearRange(uint32_t rangeStartBit, uint32_t rangeEndBit)◆ 

Clears a range of bits [rangeStartBit:rangeEndBit) in the BitSet.