[][src]Struct radix_trie::NibbleVec

pub struct NibbleVec<A> where
    A: Array<Item = u8>, 
{ /* fields omitted */ }

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

impl<A> NibbleVec<A> where
    A: Array<Item = u8>, 
[src]

pub fn new() -> NibbleVec<A>[src]

Create an empty nibble vector.

pub fn from_byte_vec(vec: Vec<u8>) -> NibbleVec<A>[src]

Create a nibble vector from a vector of bytes.

Each byte is split into two 4-bit entries (MSB, LSB).

pub fn as_bytes(&self) -> &[u8][src]

Returns a byte slice of the nibble vector's contents.

pub fn into_bytes(self) -> Vec<u8>[src]

Converts a nibble vector into a byte vector.

This consumes the nibble vector, so we do not need to copy its contents.

pub fn len(&self) -> usize[src]

Get the number of elements stored in the vector.

pub fn is_empty(&self) -> bool[src]

Returns true if the nibble vector has a length of 0.

pub fn get(&self, idx: usize) -> u8[src]

Fetch a single entry from the vector.

Guaranteed to be a value in the interval [0, 15].

Panics if idx >= self.len().

pub fn push(&mut self, val: u8)[src]

Add a single nibble to the vector.

Only the 4 least-significant bits of the value are used.

pub fn split(&mut self, idx: usize) -> NibbleVec<A>[src]

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().

pub fn join(self, other: &NibbleVec<A>) -> NibbleVec<A>[src]

Append another nibble vector whilst consuming this vector.

Trait Implementations

impl<A> Clone for NibbleVec<A> where
    A: Clone + Array<Item = u8>, 
[src]

impl<A> Debug for NibbleVec<A> where
    A: Array<Item = u8>, 
[src]

impl<A> Default for NibbleVec<A> where
    A: Default + Array<Item = u8>, 
[src]

impl<A> Eq for NibbleVec<A> where
    A: Array<Item = u8>, 
[src]

impl<'a, A> From<&'a [u8]> for NibbleVec<A> where
    A: Array<Item = u8>, 
[src]

impl<A> From<Vec<u8>> for NibbleVec<A> where
    A: Array<Item = u8>, 
[src]

impl<'a, A> Into<Vec<u8>> for &'a NibbleVec<A> where
    A: Array<Item = u8>, 
[src]

impl<A> Into<Vec<u8>> for NibbleVec<A> where
    A: Array<Item = u8>, 
[src]

impl<A> PartialEq<[u8]> for NibbleVec<A> where
    A: Array<Item = u8>, 
[src]

Compare a NibbleVec and a slice of bytes element-by-element. Bytes are not interpreted as two NibbleVec entries.

impl<A> PartialEq<NibbleVec<A>> for NibbleVec<A> where
    A: Array<Item = u8>, 
[src]

Auto Trait Implementations

impl<A> RefUnwindSafe for NibbleVec<A> where
    A: RefUnwindSafe

impl<A> Send for NibbleVec<A>

impl<A> Sync for NibbleVec<A> where
    A: Sync

impl<A> Unpin for NibbleVec<A> where
    A: Unpin

impl<A> UnwindSafe for NibbleVec<A> where
    A: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.