Trait InnerNode

Source
pub trait InnerNode<E: Edge>:
    Sized
    + Eq
    + Hash
    + DropWith<E> {
    type ChildrenIter<'a>: ExactSizeIterator<Item = Borrowed<'a, E>>
       where Self: 'a,
             E: 'a;

    const ARITY: usize;

    // Required methods
    fn new(level: LevelNo, children: impl IntoIterator<Item = E>) -> Self;
    fn check_level(&self, check: impl FnOnce(LevelNo) -> bool) -> bool;
    fn assert_level_matches(&self, level: LevelNo);
    fn children(&self) -> Self::ChildrenIter<'_>;
    fn child(&self, n: usize) -> Borrowed<'_, E>;
    unsafe fn set_child(&self, n: usize, child: E) -> E;
    fn ref_count(&self) -> usize;
}
Expand description

Node in a decision diagram

Eq and Hash should consider the children only, in particular no level information. This means that if Self implements HasLevel, HasLevel::set_level() may be called while the node is present in a LevelView. This is not the case for InnerNode::set_child(): The user must remove the node from the LevelView before setting the children (and re-insert it afterwards).

Required Associated Constants§

Source

const ARITY: usize

The node’s arity (upper bound)

Required Associated Types§

Source

type ChildrenIter<'a>: ExactSizeIterator<Item = Borrowed<'a, E>> where Self: 'a, E: 'a

Iterator over children of an inner node

Required Methods§

Source

fn new(level: LevelNo, children: impl IntoIterator<Item = E>) -> Self

Create a new node

Note that this does not apply any reduction rules. A node type that does not store levels internally (does not implement HasLevel) may simply ignore the level parameter.

Panics if children’s length does not match the node’s requirements (typically, the length should be Self::ARITY, but some node types may deviate from that).

Source

fn check_level(&self, check: impl FnOnce(LevelNo) -> bool) -> bool

Returns the result of check applied to the node’s level in case this node type stores levels, otherwise returns true.

Use HasLevel::level() if you require your nodes to store the level number and want to get the level number.

Source

fn assert_level_matches(&self, level: LevelNo)

Panics if the node types stores a level and the node’s level is not level

Source

fn children(&self) -> Self::ChildrenIter<'_>

Get the children of this node as an iterator

Source

fn child(&self, n: usize) -> Borrowed<'_, E>

Get the n-th child of this node

Source

unsafe fn set_child(&self, n: usize, child: E) -> E

Set the n-th child of this node

Returns the previous n-th child.

Note that this function may also change the node’s hash value etc., so in case the node is stored in a hash table (LevelView), it needs to be removed before calling this method.

Panics if the node does not have an n-th child.

§Safety

The caller must have exclusive access to the node. In the first place, this is granted by acquiring an exclusive manager lock (Function::with_manager_exclusive() or ManagerRef::with_manager_exclusive()). However, exclusive access to some nodes may be delegated to other threads (which is the reason why we only require a shared and not a mutable manager reference). Furthermore, there must not be a borrowed child (obtained via InnerNode::children()).

Source

fn ref_count(&self) -> usize

Get the node’s reference count

This ignores all internal references used by the manager implementation.

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.

Implementors§