IndexContainersBLBitSet
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

BLBitSet::~BLBitSet()noexcept[¶]

Destroys the BitSet.

BLBitSet::operator bool() constexplicitnoexcept[¶]

Tests whether the BitSet has a content.

Note
This is essentially the opposite of empty().

BLBitSet& BLBitSet::operator=(
BLBitSet&& other
)noexcept[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
)noexcept[2/2][¶]

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

BLResult BLBitSet::reset()noexcept[¶]

Clears the content of the BitSet and releases its data.

After reset the BitSet content matches a default constructed instance.

void BLBitSet::swap()noexcept[¶]

Swaps the content of this string with the other string.

bool BLBitSet::empty() constnoexcept[¶]

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

Returns true if the BitSet's size is zero.

uint32_t BLBitSet::segmentCount() constnoexcept[¶]

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() constnoexcept[¶]

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
) constnoexcept[¶]

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() constnoexcept[¶]

Returns the number of bits set in the BitSet.

uint32_t BLBitSet::cardinalityInRange(
uint32_t startBit,
uint32_t endBit
) constnoexcept[¶]

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

BLResult BLBitSet::getData() constnoexcept[¶]

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
) constnoexcept[¶]

Returns a bit-value at the given bitIndex.

bool BLBitSet::hasBitsInRange(
uint32_t startBit,
uint32_t endBit
) constnoexcept[¶]

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

bool BLBitSet::subsumes(
const BLBitSetCore& other
) constnoexcept[¶]

Returns whether this BitSet subsumes other.

bool BLBitSet::intersects(
const BLBitSetCore& other
) constnoexcept[¶]

Returns whether this BitSet intersects with other.

bool BLBitSet::equals(
const BLBitSetCore& other
) constnoexcept[¶]

Returns whether this BitSet and other are bitwise equal.

int BLBitSet::compare(
const BLBitSetCore& other
) constnoexcept[¶]

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

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

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

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

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

BLResult BLBitSet::assignDeep(
const BLBitSetCore& other
)noexcept[¶]

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

BLResult BLBitSet::assignRange(
uint32_t startBit,
uint32_t endBit
)noexcept[¶]

Replaces the content of the BitSet by the given range.

BLResult BLBitSet::assignWords(
uint32_t startWord,
const uint32_t* wordData,
uint32_t wordCount
)noexcept[¶]

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

BLResult BLBitSet::clear()noexcept[¶]

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

BLResult BLBitSet::shrink()noexcept[¶]

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

BLResult BLBitSet::optimize()noexcept[¶]

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
)noexcept[¶]

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

BLResult BLBitSet::truncate(
uint32_t n
)noexcept[¶]

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

BLResult BLBitSet::addBit(
uint32_t bitIndex
)noexcept[¶]

Adds a bit to the BitSet at the given index.

BLResult BLBitSet::addRange(
uint32_t rangeStartBit,
uint32_t rangeEndBit
)noexcept[¶]

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

BLResult BLBitSet::addWords(
uint32_t startWord,
const uint32_t* wordData,
uint32_t wordCount
)noexcept[¶]

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

BLResult BLBitSet::clearBit(
uint32_t bitIndex
)noexcept[¶]

Clears a bit in the BitSet at the given index.

BLResult BLBitSet::clearRange(
uint32_t rangeStartBit,
uint32_t rangeEndBit
)noexcept[¶]

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