Crate smallbitvec

Source
Expand description

SmallBitVec is a bit vector, a vector of single-bit values stored compactly in memory.

SmallBitVec grows dynamically, like the standard Vec<T> type. It can hold up to about one word of bits inline (without a separate heap allocation). If the number of bits exceeds this inline capacity, it will allocate a buffer on the heap.

ยงExample

use smallbitvec::SmallBitVec;

let mut v = SmallBitVec::new();
v.push(true);
v.push(false);

assert_eq!(v[0], true);
assert_eq!(v[1], false);

Macrosยง

const_debug_assert_le ๐Ÿ”’
sbvec
Creates a SmallBitVec containing the arguments.

Structsยง

Header ๐Ÿ”’
Data stored at the start of the heap allocation.
IntoIter
An iterator that owns a SmallBitVec and yields its bits as bool values.
Iter
An iterator that borrows a SmallBitVec and yields its bits as bool values.
SmallBitVec
A resizable bit vector, optimized for size and inline storage.
VecRange
An immutable view of a range of bits from a borrowed SmallBitVec.

Enumsยง

InternalStorage
A typed representation of a SmallBitVecโ€™s internal storage.

Constantsยง

HEAP_FLAG ๐Ÿ”’
If the rightmost bit of data is set, then the remaining bits of data are a pointer to a heap allocation.

Functionsยง

bits_per_storage ๐Ÿ”’
The number of bits in one Storage.
buffer_len ๐Ÿ”’
The minimum number of Storage elements to hold at least cap bits.
header_len ๐Ÿ”’
The number of Storage elements to allocate to hold a header.
inline_bits ๐Ÿ”’
Total number of bits per word.
inline_capacity ๐Ÿ”’
For an inline vector, all bits except two can be used as storage capacity:
inline_index ๐Ÿ”’
An inline vector with the nth bit set.
inline_ones ๐Ÿ”’
An inline vector with the leftmost n bits set.
inline_shift ๐Ÿ”’
Left shift amount to access the nth bit

Type Aliasesยง

Storage ๐Ÿ”’
The allocation will contain a Header followed by a Storage buffer.