Trait charcoal::traversal::TraversableMut[][src]

pub trait TraversableMut: Traversable {
    type PackedChildren: IntoIterator<Item = Self::Leaf>;

    const CAN_REMOVE_INDIVIDUAL_CHILDREN: bool;
    const CAN_PACK_CHILDREN: bool;

    fn value_mut_of(
        &mut self,
        cursor: &Self::Cursor
    ) -> NodeValue<&mut Self::Branch, &mut Self::Leaf>;
fn try_remove_leaf<BtL: FnOnce(Self::Branch) -> Self::Leaf>(
        &mut self,
        cursor: &Self::Cursor,
        branch_to_leaf: BtL
    ) -> Result<Self::Leaf, TryRemoveLeafError>;
fn try_remove_branch_into<BtL: FnOnce(Self::Branch) -> Self::Leaf, C: FnMut(Self::Leaf)>(
        &mut self,
        cursor: &Self::Cursor,
        branch_to_leaf: BtL,
        collector: C
    ) -> Result<Self::Branch, TryRemoveBranchError>;
fn try_remove_children_into<BtL: FnOnce(Self::Branch) -> Self::Leaf, C: FnMut(Self::Leaf)>(
        &mut self,
        cursor: &Self::Cursor,
        branch_to_leaf: BtL,
        collector: C
    ) -> Result<(), TryRemoveChildrenError>; fn try_remove_branch<BtL: FnOnce(Self::Branch) -> Self::Leaf>(
        &mut self,
        _cursor: &Self::Cursor,
        _branch_to_leaf: BtL
    ) -> Result<(Self::Branch, Self::PackedChildren), TryRemoveBranchError> { ... }
fn try_remove_children<BtL: FnOnce(Self::Branch) -> Self::Leaf>(
        &mut self,
        _cursor: &Self::Cursor,
        _branch_to_leaf: BtL
    ) -> Result<Self::PackedChildren, TryRemoveChildrenError> { ... }
fn step_mut<V: VisitorMut>(
        &mut self,
        visitor: V,
        cursor: CursorResult<Self::Cursor>
    ) -> Step<Self::Cursor, V::Output>
    where
        &'a mut Self: BorrowMut<V::Target>,
        Self::Cursor: From<<V::Target as Traversable>::Cursor> + Into<<V::Target as Traversable>::Cursor>
, { ... }
fn traverse_mut<V: VisitorMut>(&mut self, visitor: V) -> V::Output
    where
        &'a mut Self: BorrowMut<V::Target>,
        Self::Cursor: From<<V::Target as Traversable>::Cursor> + Into<<V::Target as Traversable>::Cursor>
, { ... }
fn traverse_mut_from<V: VisitorMut>(
        &mut self,
        starting_cursor: Self::Cursor,
        visitor: V
    ) -> V::Output
    where
        &'a mut Self: BorrowMut<V::Target>,
        Self::Cursor: From<<V::Target as Traversable>::Cursor> + Into<<V::Target as Traversable>::Cursor>
, { ... } }

Data structures which can be traversed using VisitorMuts, giving them mutable access to the stored data.

Associated Types

type PackedChildren: IntoIterator<Item = Self::Leaf>[src]

A container for the leaf children of a branch node.

Loading content...

Associated Constants

const CAN_REMOVE_INDIVIDUAL_CHILDREN: bool[src]

Whether the traversable allows removing individual children. This is true for trees which have a variable number of children for branches and false which don’t.

const CAN_PACK_CHILDREN: bool[src]

Whether the try_remove_branch and try_remove_children methods are implemented. If false, PackedChildren must be an iterator type which never yields elements, like Empty.

Loading content...

Required methods

fn value_mut_of(
    &mut self,
    cursor: &Self::Cursor
) -> NodeValue<&mut Self::Branch, &mut Self::Leaf>
[src]

Returns a mutable by-reference NodeValue of the node at the specified cursor, allowing modifications.

Panics

Required to panic if cursor value is invalid.

fn try_remove_leaf<BtL: FnOnce(Self::Branch) -> Self::Leaf>(
    &mut self,
    cursor: &Self::Cursor,
    branch_to_leaf: BtL
) -> Result<Self::Leaf, TryRemoveLeafError>
[src]

Attempts to remove a leaf node without using recursion. If its parent only had one child, it’s replaced with a leaf node, the value for which is provided by the specified closure (the previous value is passed into the closure).

Errors

Will fail in the following scenarios:

  • The node was a branch node, which would require recursion to remove, and this function explicitly does not implement recursive removal.
  • The node was the root node, which can never be removed.
  • The tree does not allow removing single leaf nodes and only allows removing all children of a branch node.

Panics

Required to panic if cursor value is invalid.

fn try_remove_branch_into<BtL: FnOnce(Self::Branch) -> Self::Leaf, C: FnMut(Self::Leaf)>(
    &mut self,
    cursor: &Self::Cursor,
    branch_to_leaf: BtL,
    collector: C
) -> Result<Self::Branch, TryRemoveBranchError>
[src]

Attempts to remove a branch node without using recursion. If its parent only had one child, it’s replaced with a leaf node, the value for which is provided by the specified closure (the previous value is passed into the closure). The removed children are put in the specified collector closure in order.

Errors

Will fail in the following scenarios:

  • The node was a leaf node. The try_remove_leaf_with method exists for that.
  • The node was the root node, which can never be removed.
  • One or more of the node’s children were a branch node, which thus would require recursion to remove.

Panics

Required to panic if cursor value is invalid.

fn try_remove_children_into<BtL: FnOnce(Self::Branch) -> Self::Leaf, C: FnMut(Self::Leaf)>(
    &mut self,
    cursor: &Self::Cursor,
    branch_to_leaf: BtL,
    collector: C
) -> Result<(), TryRemoveChildrenError>
[src]

Attempts to remove a branch node’s children without using recursion, replacing it with a leaf node, the value for which is provided by the specified closure. The removed children are put in the specified collector closure in order.

Errors

Will fail in the following scenarios:

  • The node was a leaf node, which cannot have children by definition.
  • One or more of the node’s children were a branch node, which thus would require recursion to remove.

Panics

Required to panic if cursor value is invalid.

Loading content...

Provided methods

fn try_remove_branch<BtL: FnOnce(Self::Branch) -> Self::Leaf>(
    &mut self,
    _cursor: &Self::Cursor,
    _branch_to_leaf: BtL
) -> Result<(Self::Branch, Self::PackedChildren), TryRemoveBranchError>
[src]

Attempts to remove a branch node without using recursion. If its parent only had one child, it’s replaced with a leaf node, the value for which is provided by the specified closure (the previous value is passed into the closure).

By default, this method is unimplemented!. In such a case, try_remove_branch_into can be used instead. If CAN_PACK_CHILDREN is true, then it is a logic error to leave it in that state, and the implementor should instead write a proper implementation of this method.

Errors

Will fail in the following scenarios:

  • The node was a leaf node. The try_remove_leaf_with method exists for that.
  • The node was the root node, which can never be removed.
  • One or more of the node’s children were a branch node, which thus would require recursion to remove.

Panics

Required to panic if cursor value is invalid.

fn try_remove_children<BtL: FnOnce(Self::Branch) -> Self::Leaf>(
    &mut self,
    _cursor: &Self::Cursor,
    _branch_to_leaf: BtL
) -> Result<Self::PackedChildren, TryRemoveChildrenError>
[src]

Attempts to remove a branch node’s children without using recursion, replacing it with a leaf node, the value for which is provided by the specified closure.

By default, this method is unimplemented!. In such a case, try_remove_branch_into can be used instead. If CAN_PACK_CHILDREN is true, then it is a logic error to leave it in that state, and the implementor should instead write a proper implementation of this method.

Errors

Will fail in the following scenarios:

  • The node was a leaf node, which cannot have children by definition.
  • One or more of the node’s children were a branch node, which thus would require recursion to remove.

Panics

Required to panic if cursor value is invalid.

fn step_mut<V: VisitorMut>(
    &mut self,
    visitor: V,
    cursor: CursorResult<Self::Cursor>
) -> Step<Self::Cursor, V::Output> where
    &'a mut Self: BorrowMut<V::Target>,
    Self::Cursor: From<<V::Target as Traversable>::Cursor> + Into<<V::Target as Traversable>::Cursor>, 
[src]

Performs one step of the mutating visitor from the specified cursor, returning either the cursor for the next step or the final result of the visitor if it ended.

It’s a logic error to interleave calls to step through a VisitorMut with equivalent calls for another VisitorMut or a Visitor on the same traversable. This cannot invoke undefined behavior, but may produce unexpected results, such as infinite loops or panicking.

Panics

The visitor itself may panic, but otherwise the method should not add any panics on its own.

fn traverse_mut<V: VisitorMut>(&mut self, visitor: V) -> V::Output where
    &'a mut Self: BorrowMut<V::Target>,
    Self::Cursor: From<<V::Target as Traversable>::Cursor> + Into<<V::Target as Traversable>::Cursor>, 
[src]

Mutably traverses the traversable from the root node until the end, returning the final result of the visitor.

fn traverse_mut_from<V: VisitorMut>(
    &mut self,
    starting_cursor: Self::Cursor,
    visitor: V
) -> V::Output where
    &'a mut Self: BorrowMut<V::Target>,
    Self::Cursor: From<<V::Target as Traversable>::Cursor> + Into<<V::Target as Traversable>::Cursor>, 
[src]

Mutably traverses the traversable from the specified starting point until the end, returning the final result of the visitor.

Loading content...

Implementations on Foreign Types

impl<T: Traversable + TraversableMut> TraversableMut for &mut T[src]

type PackedChildren = T::PackedChildren

Loading content...

Implementors

impl<B, L, K, S> TraversableMut for BinaryTree<B, L, K, S> where
    S: Storage<Element = Node<B, L, K>, Key = K>,
    K: Clone + Debug + Eq
[src]

This is supported on crate feature binary_tree only.

type PackedChildren = ArrayVec<[Self::Leaf; 2]>

impl<B, L, K, S> TraversableMut for FreeformTree<B, L, K, S> where
    S: Storage<Element = Node<B, L, K>, Key = K>,
    K: Clone + Debug + Eq
[src]

This is supported on crate feature freeform_tree only.

type PackedChildren = Empty<L>

impl<B, L, K, S> TraversableMut for Octree<B, L, K, S> where
    S: Storage<Element = Node<B, L, K>, Key = K>,
    K: Clone + Debug + Eq
[src]

This is supported on crate feature octree only.

type PackedChildren = PackedChildren<L>

impl<B, L, K, S> TraversableMut for Quadtree<B, L, K, S> where
    S: Storage<Element = Node<B, L, K>, Key = K>,
    K: Clone + Debug + Eq
[src]

This is supported on crate feature quadtree only.

type PackedChildren = PackedChildren<L>

Loading content...