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ยง
- Creates a
SmallBitVec
containing the arguments.
Structsยง
- Header ๐Data stored at the start of the heap allocation.
- An iterator that owns a SmallBitVec and yields its bits as
bool
values. - An iterator that borrows a SmallBitVec and yields its bits as
bool
values. - A resizable bit vector, optimized for size and inline storage.
- An immutable view of a range of bits from a borrowed SmallBitVec.
Enumsยง
- A typed representation of a
SmallBitVec
โs internal storage.
Constantsยง
- HEAP_
FLAG ๐If the rightmost bit ofdata
is set, then the remaining bits ofdata
are a pointer to a heap allocation.
Functionsยง
- bits_
per_ ๐storage The number of bits in oneStorage
. - buffer_
len ๐The minimum number ofStorage
elements to hold at leastcap
bits. - header_
len ๐The number ofStorage
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 leftmostn
bits set. - inline_
shift ๐Left shift amount to access the nth bit