Crate tinybitset

Source
Expand description

This crate provides a small, fixed size bitset type that stores its data inline rather than on the heap.

Bitsets are a data structure that can be viewed through two lenses:

  • As an array of booleans that is stored in a compressed fashion using a single bit per boolean.
  • As a set of small integers from the range [0, n), where n is the number of bits used in the bitset.

This crate supports functionality for both of these views but specializes on use-cases where only a small number of bits are needed with an upper-bound known beforehand. The TinyBitSet is copyable and the implementation assumes in many places that the data is small enough to cheaply be copied. Thus it is mostly suitable for sizes of up to 256 bits. For larger sizes, a heap-allocated crate like fixedbitset is likely a better fit.

One unique feature of this crate is that it uses const generics to have a single generic bitset type whose size and underlying storage type can be chosen with generic arguments. This also allows writing algorithms that are generic over these parameters and thus can use a different bitset size depending on the use-case.

Structs§

IntoIter
Iterator over the set bits in a bitset.
TinyBitSet
A small, fixed size bitset that stores its data inline.

Traits§

BitBlock
Integer that can be used as a block of bits in a bitset.