Trait acacia::traits::DataQuery
[−]
[src]
pub trait DataQuery: AssociatedData + Sized {
fn query_data<'a, R>(&'a self, recurse: R) -> RecurseData<'a, Self, R> where R: Fn(&Self) -> bool;
}
A tree which allows recursive queries on its associated data
Closures are used to determine the recursion behavior and what is to be computed.
Type parameters
D
is the type of the associated data.
Required Methods
fn query_data<'a, R>(&'a self, recurse: R) -> RecurseData<'a, Self, R> where R: Fn(&Self) -> bool
Compute a query on the associated data using a mutable accumulator
This method walks recursively through the tree, as deep as recurse
prescribes, and calls a function on the associated data of each node
encountered.
If an empty or leaf node is encountered, the function is called on its
associated data. For a branching node recurse
checks, whether its
subnodes should be inspected more closely. If so, this method recurses
on each subnode, otherwise it simply calls the function on its
associated data.
Parameters
- At each branching node the tree is only recursed further, iff
recurse(&node)
. f
is called on the associated data of every node reached by the recursion. This may mutably borrow its environment, which is currently the only way to obtain a result from this function.
Implementors
impl<T> DataQuery for T where T: Node<Container=Vec<T>> + AssociatedData