TrieBuilder

Struct TrieBuilder 

Source
pub struct TrieBuilder<V: Clone + Send + Sync, W, A: Allocator> { /* private fields */ }
Expand description

A Vec-like struct for assembling all the downstream branches from a path in the trie

Implementations§

Source§

impl<V: Clone + Send + Sync, W: Default, A: Allocator> TrieBuilder<V, W, A>

Source

pub fn len(&self) -> usize

Returns the number of children that have been pushed to the TrieBuilder, so far

Source

pub fn set_child_mask<C: AsMut<[W]>>(&mut self, mask: [u64; 4], children: C)

Simultaneously sets all child branches with single-byte path continuations

Panics if existing children have already been set / pushed, or if the number of bits set in mask doesn’t match children.len().

Source

pub fn push_byte(&mut self, byte: u8, w: W)

Pushes a new child branch into the TrieBuilder with the specified byte

Panics if byte <= the first byte of any previosuly pushed paths.

Source

pub fn push(&mut self, sub_path: &[u8], w: W)

Pushes a new child branch into the TrieBuilder with the specified sub_path

Panics if sub_path fails to meet any of the following conditions:

  • sub_path.len() > 0.
  • sub_path must not begin with the same byte as any previously-pushed path.
  • sub_path must alphabetically sort after all previously pushed paths.

For example, pushing b"horse" and then b"hour" is wrong. Instead you should push b"ho", and push the remaining parts of the path from the triggered closures downstream.

Source

pub fn child_mask(&self) -> [u64; 4]

Returns the child mask from the TrieBuilder, representing paths that have been pushed so far

Source

pub fn graft_at_byte<Z: ZipperSubtries<V, A>>( &mut self, byte: u8, read_zipper: &Z, )

Grafts the subtrie below the focus of the read_zipper at the specified byte

WARNING: This method is incompatible with Self::set_child_mask and must follow the same rules as Self::push_byte

Auto Trait Implementations§

§

impl<V, W, A> Freeze for TrieBuilder<V, W, A>
where A: Freeze,

§

impl<V, W, A> RefUnwindSafe for TrieBuilder<V, W, A>

§

impl<V, W, A> Send for TrieBuilder<V, W, A>
where W: Send,

§

impl<V, W, A> Sync for TrieBuilder<V, W, A>
where W: Sync,

§

impl<V, W, A> Unpin for TrieBuilder<V, W, A>
where A: Unpin, W: Unpin, V: Unpin,

§

impl<V, W, A> UnwindSafe for TrieBuilder<V, W, A>
where A: UnwindSafe, W: UnwindSafe, V: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.