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>
impl<V: Clone + Send + Sync, W: Default, A: Allocator> TrieBuilder<V, W, A>
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of children that have been pushed to the TrieBuilder, so far
Sourcepub fn set_child_mask<C: AsMut<[W]>>(&mut self, mask: [u64; 4], children: C)
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().
Sourcepub fn push_byte(&mut self, byte: u8, w: W)
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.
Sourcepub fn push(&mut self, sub_path: &[u8], w: W)
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_pathmust not begin with the same byte as any previously-pushed path.sub_pathmust 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.
Sourcepub fn child_mask(&self) -> [u64; 4]
pub fn child_mask(&self) -> [u64; 4]
Returns the child mask from the TrieBuilder, representing paths that have been pushed so far
Sourcepub fn graft_at_byte<Z: ZipperSubtries<V, A>>(
&mut self,
byte: u8,
read_zipper: &Z,
)
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