[][src]Struct lz_eytzinger_tree::NodeMut

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

Represents a borrowed node in the Eytzinger tree. This node may be used mutate this node's value and child nodes.

Methods

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

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

Gets the Eytzinger tree this node is for.

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

Gets the value stored at this node.

Examples

use lz_eytzinger_tree::{EytzingerTree, Node};

let mut tree = {
    let mut tree = EytzingerTree::<u32>::new(8);
    tree.set_root_value(5);
    tree
};

let root = tree.root_mut().unwrap();
assert_eq!(root.value(), &5);

pub fn value_mut(&mut self) -> &mut N
[src]

Gets the mutable value stored at this node.

Examples

use lz_eytzinger_tree::{EytzingerTree, Node};

let mut tree = {
    let mut tree = EytzingerTree::<u32>::new(8);
    tree.set_root_value(5);
    tree
};

let mut root = tree.root_mut().unwrap();
*root.value_mut() = 8;
assert_eq!(root.value(), &8);

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

Gets the mutable value stored at this node.

This differs from value_mut in that it takes ownership of the current node and the value is lifetime bound to the tree and not to the current node.

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

Gets the parent of this node or None is there was none.

pub fn to_parent(self) -> Result<Self, Self>
[src]

Gets the mutable paret of this node or None if there wasn't one.

This differs from parent_mut in that it takes ownership of the current node and is lifetime bound to the tree and not to the current node.

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

Gets the child of this node at the specified index or None if there wasn't one.

pub fn child_mut(&mut self, index: usize) -> Option<NodeMut<N>>
[src]

Gets the mutable child of this node at the specified index or None if there wasn't one.

pub fn to_child(self, index: usize) -> Result<Self, Self>
[src]

Gets the mutable child of this node at the specified index or None if there wasn't one.

This differs from child_mut in that it takes ownership of the current node and is lifetime bound to the tree and not to the current node.

pub fn set_child_value(&mut self, index: usize, new_value: N) -> NodeMut<N>
[src]

Sets the value of the child at the specified index.

Returns

The new mutable child.

pub fn remove_child_value(
    &mut self,
    index: usize
) -> (Option<N>, VacantEntry<N>)
[src]

Removes the child value at the specified child index. This will also remove all children of the specified child.

Returns

The old child value if there was one.

pub fn child_entry(&mut self, index: usize) -> Entry<N>
[src]

Gets the child entry of this node at the specified index. This node is not consumed in the process so the child entry is lifetime bound to this node.

pub fn to_child_entry(self, index: usize) -> Entry<'a, N>
[src]

Gets the child entry of this node at the specified index.

This differs from child_entry in that it takes ownership of the current node and the entry is lifetime bound to the tree and not to the current node.

pub fn remove(self) -> (N, VacantEntry<'a, N>)
[src]

Removes this node from the tree.

Examples

use lz_eytzinger_tree::{EytzingerTree, Node};

let mut tree = {
    let mut tree = EytzingerTree::<u32>::new(8);
    tree.set_root_value(5);
    tree
};
{
    let mut root = tree.root_mut().unwrap();
    root.remove();
}
assert_eq!(tree.root(), None);

pub fn as_node(&self) -> Node<N>
[src]

Gets a view of this mutable node as an immutable node. The resulting node is lifetime bound to this node so the immutable node may not outlive this mutable node.

Important traits for NodeChildIter<'a, N>
pub fn child_iter(&self) -> NodeChildIter<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 mut 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_mut().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<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<N>
[src]

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

pub fn split_off(self) -> EytzingerTree<N>
[src]

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: Debug> Debug for NodeMut<'a, N> where
    N: 'a, 
[src]

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

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

type Target = N

The resulting type after dereferencing.

Auto Trait Implementations

impl<'a, N> Send for NodeMut<'a, N> where
    N: Send

impl<'a, N> Sync for NodeMut<'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, 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]