[][src]Struct lz_eytzinger_tree::Node

pub struct Node<'a, N> where
    N: 'a, 
{ /* fields omitted */ }

Represents a borrowed node in the Eytzinger tree. This node may be used to navigate to parent or child nodes.

Methods

impl<'a, N> Node<'a, N>
[src]

pub fn tree(&self) -> &'a EytzingerTree<N>
[src]

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);

pub fn value(&self) -> &'a N
[src]

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);

pub fn parent(&self) -> Option<Node<'a, N>>
[src]

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));

pub fn child(&self, index: usize) -> Option<Node<'a, N>>
[src]

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);

Important traits for NodeChildIter<'a, N>
pub fn child_iter(&self) -> NodeChildIter<'a, N>
[src]

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]);

Important traits for DepthFirstIter<'a, N>
pub fn depth_first_iter(&self, order: DepthFirstOrder) -> DepthFirstIter<'a, N>
[src]

Gets a depth-first iterator over this and all child nodes.

Important traits for BreadthFirstIter<'a, N>
pub fn breadth_first_iter(&self) -> BreadthFirstIter<'a, N>
[src]

Gets a breadth-first iterator over this and all child nodes.

Trait Implementations

impl<'a, N> From<NodeMut<'a, N>> for Node<'a, N>
[src]

impl<'a, N> From<&'a NodeMut<'a, N>> for Node<'a, N>
[src]

impl<'a, N: Eq> Eq for Node<'a, N> where
    N: 'a, 
[src]

impl<'a, N> Copy for Node<'a, N>
[src]

impl<'a, N: PartialEq> PartialEq<Node<'a, N>> for Node<'a, N> where
    N: 'a, 
[src]

impl<'a, N> Clone for Node<'a, N>
[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl<'a, N: Debug> Debug for Node<'a, N> where
    N: 'a, 
[src]

impl<'a, N> Deref for Node<'a, N>
[src]

type Target = N

The resulting type after dereferencing.

impl<'a, N: Hash> Hash for Node<'a, N> where
    N: 'a, 
[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

Auto Trait Implementations

impl<'a, N> Send for Node<'a, N> where
    N: Sync

impl<'a, N> Sync for Node<'a, N> where
    N: Sync

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]