Struct radix_trie::NibbleVec [−][src]
Expand description
A data-structure for storing a sequence of 4-bit values.
Values are stored in a Vec<u8>
, with two values per byte.
Values at even indices are stored in the most-significant half of their byte, while values at odd indices are stored in the least-significant half.
Imagine a vector of MSB first bytes, and you’ll be right.
n = [_ _ | _ _ | _ _]
Implementations
Create a nibble vector from a vector of bytes.
Each byte is split into two 4-bit entries (MSB, LSB).
Converts a nibble vector into a byte vector.
This consumes the nibble vector, so we do not need to copy its contents.
Fetch a single entry from the vector.
Guaranteed to be a value in the interval [0, 15].
Panics if idx >= self.len()
.
Add a single nibble to the vector.
Only the 4 least-significant bits of the value are used.
Split the vector into two parts.
All elements at or following the given index are returned in a new NibbleVec
,
with exactly idx
elements remaining in this vector.
Panics if idx > self.len()
.
Trait Implementations
Compare a NibbleVec
and a slice of bytes element-by-element.
Bytes are not interpreted as two NibbleVec
entries.
Auto Trait Implementations
impl<A> RefUnwindSafe for NibbleVec<A> where
A: RefUnwindSafe,
impl<A> UnwindSafe for NibbleVec<A> where
A: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more