Trait charcoal::traversal::TraversableMut [−][src]
Data structures which can be traversed using VisitorMut
s, 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.
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
.
Required methods
fn value_mut_of(
&mut self,
cursor: &Self::Cursor
) -> NodeValue<&mut Self::Branch, &mut Self::Leaf>
[src]
&mut self,
cursor: &Self::Cursor
) -> NodeValue<&mut Self::Branch, &mut Self::Leaf>
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]
&mut self,
cursor: &Self::Cursor,
branch_to_leaf: BtL
) -> Result<Self::Leaf, TryRemoveLeafError>
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]
&mut self,
cursor: &Self::Cursor,
branch_to_leaf: BtL,
collector: C
) -> Result<Self::Branch, TryRemoveBranchError>
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]
&mut self,
cursor: &Self::Cursor,
branch_to_leaf: BtL,
collector: C
) -> Result<(), TryRemoveChildrenError>
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.
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]
&mut self,
_cursor: &Self::Cursor,
_branch_to_leaf: BtL
) -> Result<(Self::Branch, Self::PackedChildren), TryRemoveBranchError>
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]
&mut self,
_cursor: &Self::Cursor,
_branch_to_leaf: BtL
) -> Result<Self::PackedChildren, TryRemoveChildrenError>
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]
&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>,
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]
&'a mut Self: BorrowMut<V::Target>,
Self::Cursor: From<<V::Target as Traversable>::Cursor> + Into<<V::Target as Traversable>::Cursor>,
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]
&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>,
Mutably traverses the traversable from the specified starting point until the end, returning the final result of the visitor.
Implementations on Foreign Types
impl<T: Traversable + TraversableMut> TraversableMut for &mut T
[src]
const CAN_REMOVE_INDIVIDUAL_CHILDREN: bool
[src]
const CAN_PACK_CHILDREN: bool
[src]
type PackedChildren = T::PackedChildren
fn value_mut_of(
&mut self,
cursor: &Self::Cursor
) -> NodeValue<&mut Self::Branch, &mut Self::Leaf>
[src]
&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>
[src]
&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>
[src]
&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>
[src]
&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>
[src]
&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>
[src]
&mut self,
cursor: &Self::Cursor,
branch_to_leaf: BtL
) -> Result<Self::PackedChildren, TryRemoveChildrenError>
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]
S: Storage<Element = Node<B, L, K>, Key = K>,
K: Clone + Debug + Eq,
binary_tree
only.const CAN_REMOVE_INDIVIDUAL_CHILDREN: bool
[src]
const CAN_PACK_CHILDREN: bool
[src]
type PackedChildren = ArrayVec<[Self::Leaf; 2]>
fn value_mut_of(
&mut self,
cursor: &Self::Cursor
) -> NodeValue<&mut Self::Branch, &mut Self::Leaf>
[src]
&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>
[src]
&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>
[src]
&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>
[src]
&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>
[src]
&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>
[src]
&mut self,
cursor: &Self::Cursor,
branch_to_leaf: BtL
) -> Result<Self::PackedChildren, TryRemoveChildrenError>
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]
S: Storage<Element = Node<B, L, K>, Key = K>,
K: Clone + Debug + Eq,
freeform_tree
only.const CAN_REMOVE_INDIVIDUAL_CHILDREN: bool
[src]
type PackedChildren = Empty<L>
fn value_mut_of(
&mut self,
cursor: &Self::Cursor
) -> NodeValue<&mut Self::Branch, &mut Self::Leaf>
[src]
&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>
[src]
&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>
[src]
&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>
[src]
&mut self,
cursor: &Self::Cursor,
branch_to_leaf: BtL,
collector: C
) -> Result<(), TryRemoveChildrenError>
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]
S: Storage<Element = Node<B, L, K>, Key = K>,
K: Clone + Debug + Eq,
octree
only.const CAN_REMOVE_INDIVIDUAL_CHILDREN: bool
[src]
const CAN_PACK_CHILDREN: bool
[src]
type PackedChildren = PackedChildren<L>
fn value_mut_of(
&mut self,
cursor: &Self::Cursor
) -> NodeValue<&mut Self::Branch, &mut Self::Leaf>
[src]
&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>
[src]
&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>
[src]
&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>
[src]
&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>
[src]
&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>
[src]
&mut self,
cursor: &Self::Cursor,
branch_to_leaf: BtL
) -> Result<Self::PackedChildren, TryRemoveChildrenError>
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]
S: Storage<Element = Node<B, L, K>, Key = K>,
K: Clone + Debug + Eq,
quadtree
only.const CAN_REMOVE_INDIVIDUAL_CHILDREN: bool
[src]
const CAN_PACK_CHILDREN: bool
[src]
type PackedChildren = PackedChildren<L>
fn value_mut_of(
&mut self,
cursor: &Self::Cursor
) -> NodeValue<&mut Self::Branch, &mut Self::Leaf>
[src]
&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>
[src]
&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>
[src]
&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>
[src]
&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>
[src]
&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>
[src]
&mut self,
cursor: &Self::Cursor,
branch_to_leaf: BtL
) -> Result<Self::PackedChildren, TryRemoveChildrenError>