Blend2D
2D Vector Graphics Engine
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:
Destroys the BitSet.
Tests whether the BitSet has a content.
empty()
. Move assignment.
other
BitSet is reset by move assignment, so its state after the move operation is the same as a default constructed BitSet. Copy assignment, performs weak copy of the data held by the other
BitSet.
Clears the content of the BitSet and releases its data.
After reset the BitSet content matches a default constructed instance.
Swaps the content of this string with the other
string.
Tests whether the BitSet is empty (has no content).
Returns true
if the BitSet's size is zero.
Returns the number of segments this BitSet occupies.
Returns the number of segments this BitSet has allocated.
Returns the range of the BitSet as [startOut, endOut)
.
Returns true if the query was successful, false if the BitSet is empty.
Returns the number of bits set in the BitSet.
Returns the number of bits set in the given [startBit, endBit)
range.
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
.
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. Returns a bit-value at the given bitIndex
.
Returns whether the bit-set has at least on bit in the given range [start:end)
.
Returns whether this BitSet subsumes other
.
Returns whether this BitSet intersects with other
.
Returns whether this BitSet and other
are bitwise equal.
Compares this BitSet with other
and returns either -1
, 0
, or 1
.
Move assignment, the same as operator=
, but returns a BLResult
instead of this
.
Copy assignment, the same as operator=
, but returns a BLResult
instead of this
.
Copy assignment, but creates a deep copy of the other
BitSet instead of weak copy.
Replaces the content of the BitSet by the given range.
Replaces the content of the BitSet by bits specified by wordData
of size wordCount
[the size is in uint32_t units].
Clears the content of the BitSet without releasing its dynamically allocated data, if possible.
Shrinks the capacity of the BitSet to match the actual content.
Optimizes the BitSet by clearing unused pages and by merging continuous pages, without reallocating the BitSet. This functions should always return BL_SUCCESS
.
Bounds the BitSet to the given interval [start:end)
.
Truncates the BitSet so it's maximum bit set is less than n
.
Adds a bit to the BitSet at the given index
.
Adds a range of bits [rangeStartBit:rangeEndBit)
to the BitSet.
Adds a dense data to the BitSet starting a bit index start
.