Skip to main content

IKeyExprTree

Trait IKeyExprTree 

Source
pub trait IKeyExprTree<'a, Weight> {
    type Node: IKeyExprTreeNodeMut<Weight>;
    type TreeIterItem;
    type TreeIter: Iterator<Item = Self::TreeIterItem>;
    type IntersectionItem;
    type Intersection: Iterator<Item = Self::IntersectionItem>;
    type InclusionItem;
    type Inclusion: Iterator<Item = Self::InclusionItem>;
    type IncluderItem;
    type Includer: Iterator<Item = Self::IncluderItem>;

    // Required methods
    fn node(&'a self, key: &keyexpr) -> Option<&'a Self::Node>;
    fn tree_iter(&'a self) -> Self::TreeIter;
    fn intersecting_nodes(&'a self, key: &'a keyexpr) -> Self::Intersection;
    fn included_nodes(&'a self, key: &'a keyexpr) -> Self::Inclusion;
    fn nodes_including(&'a self, key: &'a keyexpr) -> Self::Includer;

    // Provided methods
    fn weight_at(&'a self, key: &keyexpr) -> Option<&'a Weight> { ... }
    fn key_value_pairs(
        &'a self,
    ) -> FilterMap<Self::TreeIter, fn(Self::TreeIterItem) -> Option<(OwnedKeyExpr, &'a Weight)>> 
       where Self::TreeIterItem: AsNode<Box<Self::Node>> { ... }
    fn intersecting_keys(
        &'a self,
        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,
        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,
        key: &'a keyexpr,
    ) -> FilterMap<Self::Includer, fn(Self::IncluderItem) -> Option<OwnedKeyExpr>> 
       where Self::IncluderItem: AsNode<Self::Node>,
             Self::Node: IKeyExprTreeNode<Weight> { ... }
}
Expand description

The basic immutable methods of all KeTrees.

Required Associated Types§

Source

type Node: IKeyExprTreeNodeMut<Weight>

The type of a given node in the KeTree.

The methods of nodes are exposed in the IKeyExprTreeNode and IKeyExprTreeNodeMut traits

Source

type TreeIterItem

Source

type TreeIter: Iterator<Item = Self::TreeIterItem>

Source

type IntersectionItem

Source

type Intersection: Iterator<Item = Self::IntersectionItem>

Source

type InclusionItem

Source

type Inclusion: Iterator<Item = Self::InclusionItem>

Source

type IncluderItem

Source

type Includer: Iterator<Item = Self::IncluderItem>

Required Methods§

Source

fn node(&'a self, key: &keyexpr) -> Option<&'a 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.

Source

fn tree_iter(&'a self) -> Self::TreeIter

Iterates over the whole tree, including nodes with no weight.

IKeyExprTree::key_value_pairs provides an iterator over all key-value pairs in the tree.

Source

fn intersecting_nodes(&'a self, 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.

Source

fn included_nodes(&'a self, 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.

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.

Source

fn nodes_including(&'a self, 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.

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.

Provided Methods§

Source

fn weight_at(&'a self, key: &keyexpr) -> Option<&'a Weight>

Returns a reference to the weight of the node at key if it exists.

Source

fn key_value_pairs( &'a self, ) -> FilterMap<Self::TreeIter, fn(Self::TreeIterItem) -> Option<(OwnedKeyExpr, &'a Weight)>>
where Self::TreeIterItem: AsNode<Box<Self::Node>>,

Iterates through weighted nodes, yielding their KE and Weight.

Source

fn intersecting_keys( &'a self, key: &'a keyexpr, ) -> FilterMap<Self::Intersection, fn(Self::IntersectionItem) -> Option<OwnedKeyExpr>>
where Self::IntersectionItem: AsNode<Self::Node>, Self::Node: IKeyExprTreeNode<Weight>,

Returns an iterator over the KEs contained in the tree that intersect with key

Source

fn included_keys( &'a self, key: &'a keyexpr, ) -> FilterMap<Self::Inclusion, fn(Self::InclusionItem) -> Option<OwnedKeyExpr>>
where Self::InclusionItem: AsNode<Self::Node>, Self::Node: IKeyExprTreeNode<Weight>,

Returns an iterator over the KEs contained in the tree that are included by key

Source

fn keys_including( &'a self, key: &'a keyexpr, ) -> FilterMap<Self::Includer, fn(Self::IncluderItem) -> Option<OwnedKeyExpr>>
where Self::IncluderItem: AsNode<Self::Node>, Self::Node: IKeyExprTreeNode<Weight>,

Returns an iterator over the KEs contained in the tree that include key

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<'a, Weight, Children, Wildness: IWildness> IKeyExprTree<'a, Weight> for KeBoxTree<Weight, Wildness, Children>
where Weight: 'a, Children: 'a + IChildrenProvider<Box<KeyExprTreeNode<Weight, Wildness, Children>>>, Children::Assoc: IChildren<Box<KeyExprTreeNode<Weight, Wildness, Children>>, Node = Box<KeyExprTreeNode<Weight, Wildness, Children>>> + 'a,

Source§

type Node = KeyExprTreeNode<Weight, Wildness, Children>

Source§

type TreeIterItem = <<KeBoxTree<Weight, Wildness, Children> as IKeyExprTree<'a, Weight>>::TreeIter as Iterator>::Item

Source§

type TreeIter = TreeIter<'a, Children, Box<KeyExprTreeNode<Weight, Wildness, Children>>, Weight>

Source§

type IntersectionItem = <<KeBoxTree<Weight, Wildness, Children> as IKeyExprTree<'a, Weight>>::Intersection as Iterator>::Item

Source§

type Intersection = IterOrOption<Intersection<'a, Children, Box<KeyExprTreeNode<Weight, Wildness, Children>>, Weight>, &'a <KeBoxTree<Weight, Wildness, Children> as IKeyExprTree<'a, Weight>>::Node>

Source§

type InclusionItem = <<KeBoxTree<Weight, Wildness, Children> as IKeyExprTree<'a, Weight>>::Inclusion as Iterator>::Item

Source§

type Inclusion = IterOrOption<Inclusion<'a, Children, Box<KeyExprTreeNode<Weight, Wildness, Children>>, Weight>, &'a <KeBoxTree<Weight, Wildness, Children> as IKeyExprTree<'a, Weight>>::Node>

Source§

type IncluderItem = <<KeBoxTree<Weight, Wildness, Children> as IKeyExprTree<'a, Weight>>::Includer as Iterator>::Item

Source§

type Includer = IterOrOption<Includer<'a, Children, Box<KeyExprTreeNode<Weight, Wildness, Children>>, Weight>, &'a <KeBoxTree<Weight, Wildness, Children> as IKeyExprTree<'a, Weight>>::Node>