Module bitset

Source
Expand description

A fast, efficient, sparse, & ordered unsigned integer (u32) bit set.

There are a couple of differences with super::IntSet:

  • This set is not invertible and can only record the set of integers which are members.
  • This set works only with u32 values, unlike super::IntSet which supports custom integer types.

When dealing with only u32โ€™s and invertibility is not needed then this set is slightly faster than the more generic super::IntSet.

The bitset is implemented using fixed size pages which allows it to compactly represent sparse membership. However, the set excels when set members are typically clustered together. For example when representing glyph id or unicode codepoint values in a font.

When constructing a new U32Set from an existing list of integer values the most efficient way to create the set is to initialize it from a sorted list of values via the extend() method.

Structsยง

PageInfo ๐Ÿ”’
U32Set
A fast, efficient, sparse, & ordered u32 set.
U32SetBuilder ๐Ÿ”’
This helper is used to construct U32Setโ€™s from a stream of possibly sorted values. It remembers the last page index to reduce the amount of page lookups needed when inserting sorted data. If given unsorted values it will still work correctly, but may be slower then just repeatedly calling insert() on the bitset.
U32SetRangeIter ๐Ÿ”’

Constantsยง

PAGE_BITS_LOG_2 ๐Ÿ”’

Functionsยง

default_last_page_map_index ๐Ÿ”’