Trait charcoal::traversal::Traversable [−][src]
Data structures which can be traversed using Visitor
s.
Associated Types
type Leaf
[src]
The payload of the node if it’s a leaf node.
type Branch
[src]
The payload of the node if it’s a branch node.
type Cursor: Clone + Debug + Eq
[src]
The type for the cursor which will be used for keeping track of the traversed nodes.
Must be very cheaply clonable, but not required to be Copy
. Cursors are not guaranteed to be stable — relying on their stability for memory safety might cause undefined behavior. The only case in which those keys should actually be stored for extended periods of time is when a visitor needs to remember node locations, since it’s a logic error to interleave step
/step_mut
calls for read-only and mutating visitors or for multiple mutating visitors; still, visitors should check for key error conditions and panic if those happen.
Required methods
fn advance_cursor<V>(
&self,
cursor: Self::Cursor,
direction: VisitorDirection<Self::Cursor, V>
) -> CursorResult<Self::Cursor>
[src]
&self,
cursor: Self::Cursor,
direction: VisitorDirection<Self::Cursor, V>
) -> CursorResult<Self::Cursor>
Advances the specified cursor according to the specified directions from the visitor.
Panics
Required to panic if the current cursor value is invalid, i.e. it’s impossible to determine the previously valid cursor value (as opposed to merely invalid directions but valid cursor, which can be recovered from).
fn cursor_to_root(&self) -> Self::Cursor
[src]
Returns the cursor pointing to the root node.
fn value_of(
&self,
cursor: &Self::Cursor
) -> NodeValue<&Self::Branch, &Self::Leaf>
[src]
&self,
cursor: &Self::Cursor
) -> NodeValue<&Self::Branch, &Self::Leaf>
Returns a by-reference NodeValue
of the node at the specified cursor.
Panics
Required to panic if the cursor value is invalid.
fn parent_of(&self, cursor: &Self::Cursor) -> Option<Self::Cursor>
[src]
Returns a cursor to the parent of the node at the specified cursor, or None
if that node is the root node.
Panics
Required to panic if the cursor value is invalid. If the cursor is valid but has no parent, the method must return None
instead of panicking.
fn num_children_of(&self, cursor: &Self::Cursor) -> usize
[src]
Returns the number of children of the node at the specified cursor.
Panics
Required to panic if the cursor value is invalid.
fn nth_child_of(
&self,
cursor: &Self::Cursor,
child_num: usize
) -> Option<Self::Cursor>
[src]
&self,
cursor: &Self::Cursor,
child_num: usize
) -> Option<Self::Cursor>
Returns a cursor to the *n
*th child of the node at the specified cursor, or None
if the child at that index does not exist.
Panics
Required to panic if cursor value is invalid.
Provided methods
fn step<V>(
&self,
visitor: V,
cursor: CursorResult<Self::Cursor>
) -> Step<Self::Cursor, V::Output> where
V: Visitor,
&'a Self: Borrow<V::Target>,
Self::Cursor: From<<V::Target as Traversable>::Cursor> + Into<<V::Target as Traversable>::Cursor>,
[src]
&self,
visitor: V,
cursor: CursorResult<Self::Cursor>
) -> Step<Self::Cursor, V::Output> where
V: Visitor,
&'a Self: Borrow<V::Target>,
Self::Cursor: From<<V::Target as Traversable>::Cursor> + Into<<V::Target as Traversable>::Cursor>,
Performs one step of the 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 Visitor
with equivalent calls for one or more VisitorMut
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<V>(&self, visitor: V) -> V::Output where
V: Visitor,
&'a Self: Borrow<V::Target>,
Self::Cursor: From<<V::Target as Traversable>::Cursor> + Into<<V::Target as Traversable>::Cursor>,
[src]
V: Visitor,
&'a Self: Borrow<V::Target>,
Self::Cursor: From<<V::Target as Traversable>::Cursor> + Into<<V::Target as Traversable>::Cursor>,
Traverses the traversable from the root node until the end, returning the final result of the visitor.
fn traverse_from<V>(
&self,
starting_cursor: Self::Cursor,
visitor: V
) -> V::Output where
V: Visitor,
&'a Self: Borrow<V::Target>,
Self::Cursor: From<<V::Target as Traversable>::Cursor> + Into<<V::Target as Traversable>::Cursor>,
[src]
&self,
starting_cursor: Self::Cursor,
visitor: V
) -> V::Output where
V: Visitor,
&'a Self: Borrow<V::Target>,
Self::Cursor: From<<V::Target as Traversable>::Cursor> + Into<<V::Target as Traversable>::Cursor>,
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> Traversable for &T
[src]
type Leaf = T::Leaf
type Branch = T::Branch
type Cursor = T::Cursor
fn advance_cursor<V>(
&self,
cursor: Self::Cursor,
direction: VisitorDirection<Self::Cursor, V>
) -> CursorResult<Self::Cursor>
[src]
&self,
cursor: Self::Cursor,
direction: VisitorDirection<Self::Cursor, V>
) -> CursorResult<Self::Cursor>
fn cursor_to_root(&self) -> Self::Cursor
[src]
fn value_of(
&self,
cursor: &Self::Cursor
) -> NodeValue<&Self::Branch, &Self::Leaf>
[src]
&self,
cursor: &Self::Cursor
) -> NodeValue<&Self::Branch, &Self::Leaf>
fn num_children_of(&self, cursor: &Self::Cursor) -> usize
[src]
fn parent_of(&self, cursor: &Self::Cursor) -> Option<Self::Cursor>
[src]
fn nth_child_of(
&self,
cursor: &Self::Cursor,
child_num: usize
) -> Option<Self::Cursor>
[src]
&self,
cursor: &Self::Cursor,
child_num: usize
) -> Option<Self::Cursor>
impl<T: Traversable> Traversable for &mut T
[src]
type Leaf = T::Leaf
type Branch = T::Branch
type Cursor = T::Cursor
fn advance_cursor<V>(
&self,
cursor: Self::Cursor,
direction: VisitorDirection<Self::Cursor, V>
) -> CursorResult<Self::Cursor>
[src]
&self,
cursor: Self::Cursor,
direction: VisitorDirection<Self::Cursor, V>
) -> CursorResult<Self::Cursor>
fn cursor_to_root(&self) -> Self::Cursor
[src]
fn value_of(
&self,
cursor: &Self::Cursor
) -> NodeValue<&Self::Branch, &Self::Leaf>
[src]
&self,
cursor: &Self::Cursor
) -> NodeValue<&Self::Branch, &Self::Leaf>
fn num_children_of(&self, cursor: &Self::Cursor) -> usize
[src]
fn parent_of(&self, cursor: &Self::Cursor) -> Option<Self::Cursor>
[src]
fn nth_child_of(
&self,
cursor: &Self::Cursor,
child_num: usize
) -> Option<Self::Cursor>
[src]
&self,
cursor: &Self::Cursor,
child_num: usize
) -> Option<Self::Cursor>
Implementors
impl<B, L, K, S> Traversable 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.type Branch = B
type Leaf = L
type Cursor = K
fn advance_cursor<V>(
&self,
cursor: Self::Cursor,
direction: VisitorDirection<Self::Cursor, V>
) -> Result<Self::Cursor, CursorDirectionError<Self::Cursor>>
[src]
&self,
cursor: Self::Cursor,
direction: VisitorDirection<Self::Cursor, V>
) -> Result<Self::Cursor, CursorDirectionError<Self::Cursor>>
fn cursor_to_root(&self) -> Self::Cursor
[src]
fn value_of(
&self,
cursor: &Self::Cursor
) -> NodeValue<&Self::Branch, &Self::Leaf>
[src]
&self,
cursor: &Self::Cursor
) -> NodeValue<&Self::Branch, &Self::Leaf>
fn parent_of(&self, cursor: &Self::Cursor) -> Option<Self::Cursor>
[src]
fn num_children_of(&self, cursor: &Self::Cursor) -> usize
[src]
fn nth_child_of(
&self,
cursor: &Self::Cursor,
child_num: usize
) -> Option<Self::Cursor>
[src]
&self,
cursor: &Self::Cursor,
child_num: usize
) -> Option<Self::Cursor>
impl<B, L, K, S> Traversable 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.type Leaf = L
type Branch = B
type Cursor = K
fn advance_cursor<V>(
&self,
cursor: Self::Cursor,
direction: VisitorDirection<Self::Cursor, V>
) -> CursorResult<Self::Cursor>
[src]
&self,
cursor: Self::Cursor,
direction: VisitorDirection<Self::Cursor, V>
) -> CursorResult<Self::Cursor>
fn cursor_to_root(&self) -> Self::Cursor
[src]
fn value_of(
&self,
cursor: &Self::Cursor
) -> NodeValue<&Self::Branch, &Self::Leaf>
[src]
&self,
cursor: &Self::Cursor
) -> NodeValue<&Self::Branch, &Self::Leaf>
fn parent_of(&self, cursor: &Self::Cursor) -> Option<Self::Cursor>
[src]
fn num_children_of(&self, cursor: &Self::Cursor) -> usize
[src]
fn nth_child_of(
&self,
cursor: &Self::Cursor,
child_num: usize
) -> Option<Self::Cursor>
[src]
&self,
cursor: &Self::Cursor,
child_num: usize
) -> Option<Self::Cursor>
impl<B, L, K, S> Traversable 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.type Leaf = L
type Branch = B
type Cursor = K
fn advance_cursor<V>(
&self,
cursor: Self::Cursor,
direction: VisitorDirection<Self::Cursor, V>
) -> CursorResult<Self::Cursor>
[src]
&self,
cursor: Self::Cursor,
direction: VisitorDirection<Self::Cursor, V>
) -> CursorResult<Self::Cursor>
fn cursor_to_root(&self) -> Self::Cursor
[src]
fn value_of(
&self,
cursor: &Self::Cursor
) -> NodeValue<&Self::Branch, &Self::Leaf>
[src]
&self,
cursor: &Self::Cursor
) -> NodeValue<&Self::Branch, &Self::Leaf>
fn parent_of(&self, cursor: &Self::Cursor) -> Option<Self::Cursor>
[src]
fn num_children_of(&self, cursor: &Self::Cursor) -> usize
[src]
fn nth_child_of(
&self,
cursor: &Self::Cursor,
child_num: usize
) -> Option<Self::Cursor>
[src]
&self,
cursor: &Self::Cursor,
child_num: usize
) -> Option<Self::Cursor>
impl<B, L, K, S> Traversable 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.type Leaf = L
type Branch = B
type Cursor = K
fn advance_cursor<V>(
&self,
cursor: Self::Cursor,
direction: VisitorDirection<Self::Cursor, V>
) -> CursorResult<Self::Cursor>
[src]
&self,
cursor: Self::Cursor,
direction: VisitorDirection<Self::Cursor, V>
) -> CursorResult<Self::Cursor>
fn cursor_to_root(&self) -> Self::Cursor
[src]
fn value_of(
&self,
cursor: &Self::Cursor
) -> NodeValue<&Self::Branch, &Self::Leaf>
[src]
&self,
cursor: &Self::Cursor
) -> NodeValue<&Self::Branch, &Self::Leaf>
fn parent_of(&self, cursor: &Self::Cursor) -> Option<Self::Cursor>
[src]
fn num_children_of(&self, cursor: &Self::Cursor) -> usize
[src]
fn nth_child_of(
&self,
cursor: &Self::Cursor,
child_num: usize
) -> Option<Self::Cursor>
[src]
&self,
cursor: &Self::Cursor,
child_num: usize
) -> Option<Self::Cursor>