pub struct Node<'a, N>where
N: 'a,{ /* private fields */ }
Expand description
Represents a borrowed node in the Eytzinger tree. This node may be used to navigate to parent or child nodes.
Implementations§
Source§impl<'a, N> Node<'a, N>
impl<'a, N> Node<'a, N>
Sourcepub fn tree(&self) -> &'a EytzingerTree<N>
pub fn tree(&self) -> &'a EytzingerTree<N>
Gets the Eytzinger tree this node is for.
§Examples
use lz_eytzinger_tree::{EytzingerTree, Node};
let tree = {
let mut tree = EytzingerTree::<u32>::new(8);
tree.set_root_value(5);
tree
};
let root = tree.root().unwrap();
assert_eq!(root.tree(), &tree);
Sourcepub fn value(&self) -> &'a N
pub fn value(&self) -> &'a N
Gets the value stored at this node.
§Examples
use lz_eytzinger_tree::{EytzingerTree, Node};
let tree = {
let mut tree = EytzingerTree::<u32>::new(8);
tree.set_root_value(5);
tree
};
let root = tree.root().unwrap();
assert_eq!(root.value(), &5);
Sourcepub fn parent(&self) -> Option<Node<'a, N>>
pub fn parent(&self) -> Option<Node<'a, N>>
Gets the parent of this node or None
is there was none.
§Examples
use lz_eytzinger_tree::{EytzingerTree, Node};
let tree = {
let mut tree = EytzingerTree::<u32>::new(8);
{
let mut root = tree.set_root_value(5);
root.set_child_value(2, 3);
}
tree
};
let root = tree.root().unwrap();
let child = root.child(2).unwrap();
assert_eq!(child.parent(), Some(root));
Sourcepub fn child(&self, index: usize) -> Option<Node<'a, N>>
pub fn child(&self, index: usize) -> Option<Node<'a, N>>
Gets the child of this node at the specified index or None
if there wasn’t one.
§Examples
use lz_eytzinger_tree::{EytzingerTree, Node};
let tree = {
let mut tree = EytzingerTree::<u32>::new(8);
{
let mut root = tree.set_root_value(5);
root.set_child_value(2, 3);
}
tree
};
let root = tree.root().unwrap();
let child = root.child(2).unwrap();
assert_eq!(child.value(), &3);
Sourcepub fn child_iter(&self) -> NodeChildIter<'a, N> ⓘ
pub fn child_iter(&self) -> NodeChildIter<'a, N> ⓘ
Gets an iterator over the immediate children of this node. This only includes children for which there is a node.
§Examples
use lz_eytzinger_tree::{EytzingerTree, Node};
let tree = {
let mut tree = EytzingerTree::<u32>::new(8);
{
let mut root = tree.set_root_value(5);
root.set_child_value(0, 1);
root.set_child_value(2, 3);
}
tree
};
let root = tree.root().unwrap();
let child_values: Vec<_> = root.child_iter().map(|n| n.value()).collect();
assert_eq!(child_values, vec![&1, &3]);
Sourcepub fn depth_first_iter(&self, order: DepthFirstOrder) -> DepthFirstIter<'a, N> ⓘ
pub fn depth_first_iter(&self, order: DepthFirstOrder) -> DepthFirstIter<'a, N> ⓘ
Gets a depth-first iterator over this and all child nodes.
Sourcepub fn breadth_first_iter(&self) -> BreadthFirstIter<'a, N> ⓘ
pub fn breadth_first_iter(&self) -> BreadthFirstIter<'a, N> ⓘ
Gets a breadth-first iterator over this and all child nodes.
Trait Implementations§
impl<'a, N> Copy for Node<'a, N>
impl<'a, N> Eq for Node<'a, N>where
N: 'a + Eq,
impl<'a, N> StructuralPartialEq for Node<'a, N>where
N: 'a,
Auto Trait Implementations§
impl<'a, N> Freeze for Node<'a, N>
impl<'a, N> RefUnwindSafe for Node<'a, N>where
N: RefUnwindSafe,
impl<'a, N> Send for Node<'a, N>where
N: Sync,
impl<'a, N> Sync for Node<'a, N>where
N: Sync,
impl<'a, N> Unpin for Node<'a, N>
impl<'a, N> UnwindSafe for Node<'a, N>where
N: RefUnwindSafe,
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
Mutably borrows from an owned value. Read more