pub struct Tree<TP: TreeProperties> { /* private fields */ }
Expand description
Tree
is a binary tree with path-shortening.
Nodes are either inner nodes with two child nodes, or leaf nodes. Both node types carry keys and values, leaf nodes an additional leaf value (of different type).
Implementations§
source§impl<TP: TreeProperties> Tree<TP>
impl<TP: TreeProperties> Tree<TP>
sourcepub fn set_leaf_value(&mut self, key: TP::Key, value: TP::LeafValue)
pub fn set_leaf_value(&mut self, key: TP::Key, value: TP::LeafValue)
Set a new prefix => value mapping.
Leaf values are designed to split all values into prefixes that either have a leaf value or no leaf value set.
Sibling prefixes that share the same leaf value are merged.
sourcepub fn get<'r>(&'r self, key: &TP::Key) -> Option<&'r Node<TP>>
pub fn get<'r>(&'r self, key: &TP::Key) -> Option<&'r Node<TP>>
Get reference to node with exact key
sourcepub fn get_mut<'r>(&'r mut self, key: &TP::Key) -> Option<&'r mut Node<TP>>
pub fn get_mut<'r>(&'r mut self, key: &TP::Key) -> Option<&'r mut Node<TP>>
Get mutable reference to node with exact key
sourcepub fn goto_insert<'r>(
&'r self,
key: &TP::Key,
) -> Option<InsertPositionWith<&'r Node<TP>>>
pub fn goto_insert<'r>( &'r self, key: &TP::Key, ) -> Option<InsertPositionWith<&'r Node<TP>>>
Goto insert position for given key
sourcepub fn goto_mut_insert<'r>(
&'r mut self,
key: &TP::Key,
) -> Option<InsertPositionWith<&'r mut Node<TP>>>
pub fn goto_mut_insert<'r>( &'r mut self, key: &TP::Key, ) -> Option<InsertPositionWith<&'r mut Node<TP>>>
Goto mutable insert position for given key
sourcepub fn get_longest_prefix_with<'r, F>(
&'r self,
key: &TP::Key,
callback: F,
) -> Option<&'r Node<TP>>
pub fn get_longest_prefix_with<'r, F>( &'r self, key: &TP::Key, callback: F, ) -> Option<&'r Node<TP>>
Get a reference to the node with the longest prefix satisfying callback of the target key
sourcepub fn get_longest_prefix_mut_with<'r, F>(
&'r mut self,
key: &TP::Key,
callback: F,
) -> Option<&'r mut Node<TP>>
pub fn get_longest_prefix_mut_with<'r, F>( &'r mut self, key: &TP::Key, callback: F, ) -> Option<&'r mut Node<TP>>
Get a reference to the node with the longest prefix satisfying callback of the target key
sourcepub fn get_most_specific<'r>(&'r self, key: &TP::Key) -> Option<&'r Node<TP>>
pub fn get_most_specific<'r>(&'r self, key: &TP::Key) -> Option<&'r Node<TP>>
Get a reference to the node with the longest prefix of the target key
sourcepub fn get_most_specific_mut<'r>(
&'r mut self,
key: &TP::Key,
) -> Option<&'r mut Node<TP>>
pub fn get_most_specific_mut<'r>( &'r mut self, key: &TP::Key, ) -> Option<&'r mut Node<TP>>
Get a mutable reference to the node with the longest prefix of the target key
sourcepub fn iter_path(&self, key: TP::Key) -> IterPath<'_, TP> ⓘ
pub fn iter_path(&self, key: TP::Key) -> IterPath<'_, TP> ⓘ
Iterate over nodes of tree that are a prefix of target key
sourcepub fn iter_pre_order(&self) -> IterPreOrder<'_, TP> ⓘ
pub fn iter_pre_order(&self) -> IterPreOrder<'_, TP> ⓘ
Iterate over nodes of tree depth-first pre-order
sourcepub fn iter_in_order(&self) -> IterInOrder<'_, TP> ⓘ
pub fn iter_in_order(&self) -> IterInOrder<'_, TP> ⓘ
Iterate over nodes of tree depth-first in-order
sourcepub fn iter_post_order(&self) -> IterPostOrder<'_, TP> ⓘ
pub fn iter_post_order(&self) -> IterPostOrder<'_, TP> ⓘ
Iterate over nodes of tree depth-first post-order
sourcepub fn iter_leaf(&self) -> IterLeaf<'_, TP> ⓘ
pub fn iter_leaf(&self) -> IterLeaf<'_, TP> ⓘ
Iterate over nodes and leaf values of tree in-order
sourcepub fn iter_leaf_full(&self) -> IterLeafFull<'_, TP> ⓘ
pub fn iter_leaf_full(&self) -> IterLeafFull<'_, TP> ⓘ
Iterate over nodes and leaf values and uncovered keys of tree in-order
sourcepub fn walk_mut<D, A>(&mut self) -> WalkMutOwned<'_, TP, D, A>
pub fn walk_mut<D, A>(&mut self) -> WalkMutOwned<'_, TP, D, A>
Walk mutable tree
sourcepub fn iter_mut_path(&mut self, key: TP::Key) -> MutPath<'_, TP>
pub fn iter_mut_path(&mut self, key: TP::Key) -> MutPath<'_, TP>
Iterate over keys and mutable values of tree that are a prefix of target key
sourcepub fn iter_mut_pre_order(&mut self) -> IterMutOwnedPreOrder<'_, TP> ⓘ
pub fn iter_mut_pre_order(&mut self) -> IterMutOwnedPreOrder<'_, TP> ⓘ
Iterate over keys and mutable values of tree depth-first pre-order
sourcepub fn iter_mut_in_order(&mut self) -> IterMutOwnedInOrder<'_, TP> ⓘ
pub fn iter_mut_in_order(&mut self) -> IterMutOwnedInOrder<'_, TP> ⓘ
Iterate over keys and mutable values of tree depth-first in-order
sourcepub fn iter_mut_post_order(&mut self) -> IterMutOwnedPostOrder<'_, TP> ⓘ
pub fn iter_mut_post_order(&mut self) -> IterMutOwnedPostOrder<'_, TP> ⓘ
Iterate over keys and mutable values of tree depth-first post-order
sourcepub fn iter_mut_leaf(&mut self) -> IterMutOwnedLeaf<'_, TP> ⓘ
pub fn iter_mut_leaf(&mut self) -> IterMutOwnedLeaf<'_, TP> ⓘ
Iterate over keys and mutable leaf values of tree in-order
sourcepub fn iter_mut_leaf_full(&mut self) -> IterMutOwnedLeafFull<'_, TP> ⓘ
pub fn iter_mut_leaf_full(&mut self) -> IterMutOwnedLeafFull<'_, TP> ⓘ
Iterate over keys and mutable leaf values and uncovered keys of tree in-order
Trait Implementations§
Auto Trait Implementations§
impl<TP> Freeze for Tree<TP>where
<TP as TreeProperties>::Key: Freeze,
<TP as TreeProperties>::Value: Freeze,
<TP as TreeProperties>::LeafValue: Freeze,
impl<TP> RefUnwindSafe for Tree<TP>where
<TP as TreeProperties>::Key: RefUnwindSafe,
<TP as TreeProperties>::Value: RefUnwindSafe,
<TP as TreeProperties>::LeafValue: RefUnwindSafe,
impl<TP> Send for Tree<TP>where
<TP as TreeProperties>::Key: Send,
<TP as TreeProperties>::Value: Send,
<TP as TreeProperties>::LeafValue: Send,
impl<TP> Sync for Tree<TP>where
<TP as TreeProperties>::Key: Sync,
<TP as TreeProperties>::Value: Sync,
<TP as TreeProperties>::LeafValue: Sync,
impl<TP> Unpin for Tree<TP>where
<TP as TreeProperties>::Key: Unpin,
<TP as TreeProperties>::Value: Unpin,
<TP as TreeProperties>::LeafValue: Unpin,
impl<TP> UnwindSafe for Tree<TP>where
<TP as TreeProperties>::Key: UnwindSafe,
<TP as TreeProperties>::Value: UnwindSafe,
<TP as TreeProperties>::LeafValue: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)