pub trait ITokenKeyExprTree<'a, Weight, Token> {
Show 37 associated items
type Node: IKeyExprTreeNode<Weight>;
type NodeMut: IKeyExprTreeNodeMut<Weight>;
type TreeIterItem;
type TreeIter: Iterator<Item = Self::TreeIterItem>;
type TreeIterItemMut;
type TreeIterMut: Iterator<Item = Self::TreeIterItemMut>;
type IntersectionItem;
type Intersection: Iterator<Item = Self::IntersectionItem>;
type IntersectionItemMut;
type IntersectionMut: Iterator<Item = Self::IntersectionItemMut>;
type InclusionItem;
type Inclusion: Iterator<Item = Self::InclusionItem>;
type InclusionItemMut;
type InclusionMut: Iterator<Item = Self::InclusionItemMut>;
type IncluderItem;
type Includer: Iterator<Item = Self::IncluderItem>;
type IncluderItemMut;
type IncluderMut: Iterator<Item = Self::IncluderItemMut>;
type PruneNode: IKeyExprTreeNodeMut<Weight>;
// Required methods
fn node(&'a self, token: &'a Token, key: &keyexpr) -> Option<Self::Node>;
fn node_mut(
&'a self,
token: &'a mut Token,
key: &keyexpr,
) -> Option<Self::NodeMut>;
fn node_or_create(
&'a self,
token: &'a mut Token,
key: &keyexpr,
) -> Self::NodeMut;
fn tree_iter(&'a self, token: &'a Token) -> Self::TreeIter;
fn tree_iter_mut(&'a self, token: &'a mut Token) -> Self::TreeIterMut;
fn intersecting_nodes(
&'a self,
token: &'a Token,
key: &'a keyexpr,
) -> Self::Intersection;
fn intersecting_nodes_mut(
&'a self,
token: &'a mut Token,
key: &'a keyexpr,
) -> Self::IntersectionMut;
fn included_nodes(
&'a self,
token: &'a Token,
key: &'a keyexpr,
) -> Self::Inclusion;
fn included_nodes_mut(
&'a self,
token: &'a mut Token,
key: &'a keyexpr,
) -> Self::InclusionMut;
fn nodes_including(
&'a self,
token: &'a Token,
key: &'a keyexpr,
) -> Self::Includer;
fn nodes_including_mut(
&'a self,
token: &'a mut Token,
key: &'a keyexpr,
) -> Self::IncluderMut;
fn prune_where<F: FnMut(&mut Self::PruneNode) -> bool>(
&self,
token: &mut Token,
predicate: F,
);
// Provided methods
fn insert(
&'a self,
token: &'a mut Token,
at: &keyexpr,
weight: Weight,
) -> Option<Weight> { ... }
fn remove(
&'a mut self,
token: &'a mut Token,
key: &keyexpr,
) -> Option<Weight> { ... }
fn intersecting_keys(
&'a self,
token: &'a Token,
key: &'a keyexpr,
) -> FilterMap<Self::Intersection, fn(Self::IntersectionItem) -> Option<OwnedKeyExpr>> ⓘ
where Self::IntersectionItem: AsNode<Self::Node>,
Self::Node: IKeyExprTreeNode<Weight> { ... }
fn included_keys(
&'a self,
token: &'a Token,
key: &'a keyexpr,
) -> FilterMap<Self::Inclusion, fn(Self::InclusionItem) -> Option<OwnedKeyExpr>> ⓘ
where Self::InclusionItem: AsNode<Self::Node>,
Self::Node: IKeyExprTreeNode<Weight> { ... }
fn keys_including(
&'a self,
token: &'a Token,
key: &'a keyexpr,
) -> FilterMap<Self::Includer, fn(Self::IncluderItem) -> Option<OwnedKeyExpr>> ⓘ
where Self::IncluderItem: AsNode<Self::Node>,
Self::Node: IKeyExprTreeNode<Weight> { ... }
fn prune(&self, token: &mut Token) { ... }
}
Expand description
The basic operations of a KeTree when a Token is necessary to access data.
Required Associated Types§
Sourcetype Node: IKeyExprTreeNode<Weight>
type Node: IKeyExprTreeNode<Weight>
An immutable guard to a node of the tree.
type NodeMut: IKeyExprTreeNodeMut<Weight>
type TreeIterItem
type TreeIter: Iterator<Item = Self::TreeIterItem>
type TreeIterItemMut
type TreeIterMut: Iterator<Item = Self::TreeIterItemMut>
type IntersectionItem
type Intersection: Iterator<Item = Self::IntersectionItem>
type IntersectionItemMut
type IntersectionMut: Iterator<Item = Self::IntersectionItemMut>
type InclusionItem
type Inclusion: Iterator<Item = Self::InclusionItem>
type InclusionItemMut
type InclusionMut: Iterator<Item = Self::InclusionItemMut>
type IncluderItem
type Includer: Iterator<Item = Self::IncluderItem>
type IncluderItemMut
type IncluderMut: Iterator<Item = Self::IncluderItemMut>
type PruneNode: IKeyExprTreeNodeMut<Weight>
Required Methods§
Sourcefn node(&'a self, token: &'a Token, key: &keyexpr) -> Option<Self::Node>
fn node(&'a self, token: &'a Token, key: &keyexpr) -> Option<Self::Node>
Accesses the node at key
if it exists, treating KEs as if they were completely verbatim keys.
Returns None
if key
is not present in the KeTree.
Sourcefn node_mut(
&'a self,
token: &'a mut Token,
key: &keyexpr,
) -> Option<Self::NodeMut>
fn node_mut( &'a self, token: &'a mut Token, key: &keyexpr, ) -> Option<Self::NodeMut>
Mutably accesses the node at key
if it exists, treating KEs as if they were completely verbatim keys.
Returns None
if key
is not present. Use IKeyExprTreeMut::node_mut_or_create
if you wish to construct the node if it doesn’t exist.
Sourcefn node_or_create(
&'a self,
token: &'a mut Token,
key: &keyexpr,
) -> Self::NodeMut
fn node_or_create( &'a self, token: &'a mut Token, key: &keyexpr, ) -> Self::NodeMut
Mutably accesses the node at key
, creating it if necessary.
Sourcefn tree_iter(&'a self, token: &'a Token) -> Self::TreeIter
fn tree_iter(&'a self, token: &'a Token) -> Self::TreeIter
Iterates over the whole tree, including nodes with no weight.
Sourcefn tree_iter_mut(&'a self, token: &'a mut Token) -> Self::TreeIterMut
fn tree_iter_mut(&'a self, token: &'a mut Token) -> Self::TreeIterMut
Iterates over the whole tree, including nodes with no weight.
Sourcefn intersecting_nodes(
&'a self,
token: &'a Token,
key: &'a keyexpr,
) -> Self::Intersection
fn intersecting_nodes( &'a self, token: &'a Token, key: &'a keyexpr, ) -> Self::Intersection
Iterates over all nodes of the tree whose KE intersects with the given key
.
Note that nodes without a Weight
will also be yielded by the iterator.
You can obtain an iterator over key-value pairs using iter.filter_map(|node| node.weight.map(|w| (node.keyexpr(), w)))
,
keep in mind that the full keyexpr of nodes is not stored in them by default, but computed using the tree:
if you need to get a node’s key often, inserting its keyexpr in the Weight
could be a good idea.
Sourcefn intersecting_nodes_mut(
&'a self,
token: &'a mut Token,
key: &'a keyexpr,
) -> Self::IntersectionMut
fn intersecting_nodes_mut( &'a self, token: &'a mut Token, key: &'a keyexpr, ) -> Self::IntersectionMut
Iterates over all nodes of the tree whose KE intersects with the given key
.
Note that nodes without a Weight
will also be yielded by the iterator.
Sourcefn included_nodes(
&'a self,
token: &'a Token,
key: &'a keyexpr,
) -> Self::Inclusion
fn included_nodes( &'a self, token: &'a Token, key: &'a keyexpr, ) -> Self::Inclusion
Iterates over all nodes of the tree whose KE is included by the given key
.
Note that nodes without a Weight
will also be yielded by the iterator.
Sourcefn included_nodes_mut(
&'a self,
token: &'a mut Token,
key: &'a keyexpr,
) -> Self::InclusionMut
fn included_nodes_mut( &'a self, token: &'a mut Token, key: &'a keyexpr, ) -> Self::InclusionMut
Iterates over all nodes of the tree whose KE is included by the given key
.
Note that nodes without a Weight
will also be yielded by the iterator.
Sourcefn nodes_including(
&'a self,
token: &'a Token,
key: &'a keyexpr,
) -> Self::Includer
fn nodes_including( &'a self, token: &'a Token, key: &'a keyexpr, ) -> Self::Includer
Iterates over all nodes of the tree whose KE includes the given key
.
Note that nodes without a Weight
will also be yielded by the iterator.
Sourcefn nodes_including_mut(
&'a self,
token: &'a mut Token,
key: &'a keyexpr,
) -> Self::IncluderMut
fn nodes_including_mut( &'a self, token: &'a mut Token, key: &'a keyexpr, ) -> Self::IncluderMut
Iterates over all nodes of the tree whose KE includes the given key
.
Note that nodes without a Weight
will also be yielded by the iterator.
fn prune_where<F: FnMut(&mut Self::PruneNode) -> bool>( &self, token: &mut Token, predicate: F, )
Provided Methods§
Sourcefn insert(
&'a self,
token: &'a mut Token,
at: &keyexpr,
weight: Weight,
) -> Option<Weight>
fn insert( &'a self, token: &'a mut Token, at: &keyexpr, weight: Weight, ) -> Option<Weight>
Inserts a weight at key
, returning the previous weight if it existed.
Sourcefn remove(&'a mut self, token: &'a mut Token, key: &keyexpr) -> Option<Weight>
fn remove(&'a mut self, token: &'a mut Token, key: &keyexpr) -> Option<Weight>
Clears the weight of the node at key
, but doesn’t actually destroy the node.
To actually destroy nodes, ITokenKeyExprTree::prune_where
or ITokenKeyExprTree::prune
must be called.
Sourcefn intersecting_keys(
&'a self,
token: &'a Token,
key: &'a keyexpr,
) -> FilterMap<Self::Intersection, fn(Self::IntersectionItem) -> Option<OwnedKeyExpr>> ⓘ
fn intersecting_keys( &'a self, token: &'a Token, key: &'a keyexpr, ) -> FilterMap<Self::Intersection, fn(Self::IntersectionItem) -> Option<OwnedKeyExpr>> ⓘ
Returns an iterator over the KEs contained in the tree that intersect with key
Sourcefn included_keys(
&'a self,
token: &'a Token,
key: &'a keyexpr,
) -> FilterMap<Self::Inclusion, fn(Self::InclusionItem) -> Option<OwnedKeyExpr>> ⓘ
fn included_keys( &'a self, token: &'a Token, key: &'a keyexpr, ) -> FilterMap<Self::Inclusion, fn(Self::InclusionItem) -> Option<OwnedKeyExpr>> ⓘ
Returns an iterator over the KEs contained in the tree that are included by key
Sourcefn keys_including(
&'a self,
token: &'a Token,
key: &'a keyexpr,
) -> FilterMap<Self::Includer, fn(Self::IncluderItem) -> Option<OwnedKeyExpr>> ⓘ
fn keys_including( &'a self, token: &'a Token, key: &'a keyexpr, ) -> FilterMap<Self::Includer, fn(Self::IncluderItem) -> Option<OwnedKeyExpr>> ⓘ
Returns an iterator over the KEs contained in the tree that include key
fn prune(&self, token: &mut Token)
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.