pub trait TreeCollection<K, V>: TraversableCollection<K, V>where
K: PartialEq + PartialOrd + Clone + Debug + Eq + Hash,
V: PartialEq + PartialOrd + Clone + Debug,{
Show 14 methods
// Required methods
fn breadth(&self) -> usize;
fn child_nodes(&self, key: &K) -> Vec<&V>;
fn depth_of(&self, key: &K) -> isize;
fn height(&self) -> isize;
fn height_from(&self, key: &K) -> isize;
fn is_ancestor(&self, key_a: &K, key_b: &K) -> bool;
fn is_descendant(&self, key_a: &K, key_b: &K) -> bool;
fn is_leaf(&self, key: &K) -> bool;
fn is_sibling(&self, key_a: &K, key_b: &K) -> bool;
fn level_of(&self, key: &K) -> isize;
fn parent_node(&self, key: &K) -> Option<&V>;
fn root_node(&self) -> Option<&V>;
fn set_node(&mut self, pair: KeyValue<K, V>) -> V;
fn width(&self, level: usize) -> usize;
}
Required Methods§
Sourcefn breadth(&self) -> usize
fn breadth(&self) -> usize
Returns the breadth of this ‘tree’. The breadth of a ‘tree’ is the total number of leaf ‘nodes’ that it has.
Sourcefn child_nodes(&self, key: &K) -> Vec<&V>
fn child_nodes(&self, key: &K) -> Vec<&V>
Returns a list of child ‘nodes’ values belonging to the ‘node’ with the specified key. If no such ‘node’ exists or if the ‘node’ has no children, an empty vector is returned.
Sourcefn depth_of(&self, key: &K) -> isize
fn depth_of(&self, key: &K) -> isize
Returns the depth of the ‘node’ with the specified key, or returns -1 if no such ‘node’ with that key exists. The depth of a ‘node’ is the number of edges it has from the root ‘node’. This is the same as the level of a ‘node’.
Sourcefn height(&self) -> isize
fn height(&self) -> isize
Returns the height of this ‘tree’. The height of a ‘tree’ is the distance from the root ‘node’ to the leaf ‘node’ that is furthest away.
Sourcefn height_from(&self, key: &K) -> isize
fn height_from(&self, key: &K) -> isize
Returns the height of this ‘tree’ from the ‘node’ with the specified key, or returns -1 if no such ‘node’ with that key exists.
Sourcefn is_ancestor(&self, key_a: &K, key_b: &K) -> bool
fn is_ancestor(&self, key_a: &K, key_b: &K) -> bool
Returns true if the ‘node’ with the second specified key is an ancestor of the ‘node’ with the first specified key. If either key does not belong to an existing ‘node’, or the two ‘nodes’ are not ancestors, this returns false. An ancestor of a ‘node’ is a ‘node’ that can be reached by progressing up through the original ‘node’s’ parent node and its parent ‘node’ and so on.
Sourcefn is_descendant(&self, key_a: &K, key_b: &K) -> bool
fn is_descendant(&self, key_a: &K, key_b: &K) -> bool
Returns true if the ‘node’ with the second specified key is a descendant of the ‘node’ with the first specified key. If either key does not belong to an existing ‘node’, or the two ‘nodes’ are not descendants, this returns false. A descendant of a ‘node’ is a ‘node’ that is reachable from another ‘node’ by progressing down through their child ‘nodes’ and their child’s child ‘nodes’ and so on.
Sourcefn is_leaf(&self, key: &K) -> bool
fn is_leaf(&self, key: &K) -> bool
Returns true if the ‘node’ with the specified key is a leaf ‘node’. If no such ‘node’ exists, false is returned. A leaf ‘node’ is a node with no child ‘nodes’.
Sourcefn is_sibling(&self, key_a: &K, key_b: &K) -> bool
fn is_sibling(&self, key_a: &K, key_b: &K) -> bool
Returns true if the ‘node’ with the second specified key is a sibling of the ‘node’ with the first specified key. If either key does not belong to an existing ‘node’, or the two ‘nodes’ are not siblings, this returns false. A sibling of a ‘node’ is a ‘node’ that has the same parent ‘node’.
Sourcefn level_of(&self, key: &K) -> isize
fn level_of(&self, key: &K) -> isize
Returns the level of the ‘node’ with the specified key, or returns -1 if no such ‘node’ with that key exists. The level of a ‘node’ is the number of edges it has from the root ‘node’. This is the same as the depth of a ‘node’.
Sourcefn parent_node(&self, key: &K) -> Option<&V>
fn parent_node(&self, key: &K) -> Option<&V>
Returns the parent ‘node’ value of the ‘node’ with the specified key. If no such ‘node’ exists or if the ‘node’ has no parent, this returns None.
Sourcefn root_node(&self) -> Option<&V>
fn root_node(&self) -> Option<&V>
Returns the root ‘node’ value of this ‘tree’, or None if there is no root ‘node’.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.