pub struct Tree<C: Cookie, I: NodeIndex, O: OptionalNodeIndex<I>, K: NodeKey<C, I>, N> { /* private fields */ }Expand description
A vector-backed tree where you can store nodes
Implementations§
Source§impl<C: Cookie, I: NodeIndex, O: OptionalNodeIndex<I>, K: NodeKey<C, I>, N> Tree<C, I, O, K, N>
impl<C: Cookie, I: NodeIndex, O: OptionalNodeIndex<I>, K: NodeKey<C, I>, N> Tree<C, I, O, K, N>
Source§impl<C: Cookie, I: NodeIndex, O: OptionalNodeIndex<I>, K: NodeKey<C, I>, N: Default> Tree<C, I, O, K, N>
impl<C: Cookie, I: NodeIndex, O: OptionalNodeIndex<I>, K: NodeKey<C, I>, N: Default> Tree<C, I, O, K, N>
Sourcepub fn delete_children(&mut self, key: K)
pub fn delete_children(&mut self, key: K)
Remove the children of a node from the tree
Internal references to the nodes are removed (links with siblings & parent). This function behaves recursively to remove nodes from leaf to branch.
Sourcepub fn delete(&mut self, key: K)
pub fn delete(&mut self, key: K)
Remove a node and its children from the tree
Internal references to the node are removed (links with siblings & parent). This function behaves recursively to remove nodes from leaf to branch.
Sourcepub fn reset(&mut self, key: K)
pub fn reset(&mut self, key: K)
Removes the children of a node and reset its public properties to their defaults
Sourcepub fn insert_after(&mut self, prev: K, key: K)
pub fn insert_after(&mut self, prev: K, key: K)
Insert a node as the next sibling of prev
Sourcepub fn append_children(&mut self, key: K, parent: K)
pub fn append_children(&mut self, key: K, parent: K)
Adds one or multiple “children” nodes to a “parent” node
node and all it’s siblings are appended to the list
of children of parent.
Sourcepub fn replace(&mut self, old: K, new: K)
pub fn replace(&mut self, old: K, new: K)
Change references to old so that they
point to new instead and remove old
Sourcepub fn detach_children(&mut self, parent: K) -> Option<K>
pub fn detach_children(&mut self, parent: K) -> Option<K>
Detach a node from all its “children”, leaving them “orphans”
If the node had no children, None is returned.
Sourcepub fn child_index(&self, key: K) -> Option<usize>
pub fn child_index(&self, key: K) -> Option<usize>
Get the index of this node relative to its parent’s children
Sourcepub fn first_child(&self, key: K) -> Option<K>
pub fn first_child(&self, key: K) -> Option<K>
Locate the first child of a node
Sourcepub fn last_child(&self, key: K) -> Option<K>
pub fn last_child(&self, key: K) -> Option<K>
Locate the last child of a node
Sourcepub fn prev_sibling(&self, key: K) -> K
pub fn prev_sibling(&self, key: K) -> K
Locate the previous sibling of a node
Note: siblings are looping, meaning that calling this for the first child of a node will locate the last child of the node.
Sourcepub fn next_sibling(&self, key: K) -> K
pub fn next_sibling(&self, key: K) -> K
Locate the next sibling of a node
Note: siblings are looping, meaning that calling this for the last child of a node will locate the first child of the node.
Sourcepub fn is_only_child(&self, key: K) -> bool
pub fn is_only_child(&self, key: K) -> bool
Returns true if node has no sibling except itself