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§
Required Associated Types§
sourcetype ChildrenIter<'a>: ExactSizeIterator<Item = Borrowed<'a, E>>
where
Self: 'a,
E: 'a
type ChildrenIter<'a>: ExactSizeIterator<Item = Borrowed<'a, E>> where Self: 'a, E: 'a
Iterator over children of an inner node
Required Methods§
sourcefn new(level: LevelNo, children: impl IntoIterator<Item = E>) -> Self
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).
sourcefn check_level(&self, check: impl FnOnce(LevelNo) -> bool) -> bool
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.
sourcefn assert_level_matches(&self, level: LevelNo)
fn assert_level_matches(&self, level: LevelNo)
Panics if the node types stores a level and the node’s level is not
level
sourcefn children(&self) -> Self::ChildrenIter<'_>
fn children(&self) -> Self::ChildrenIter<'_>
Get the children of this node as an iterator
sourceunsafe fn set_child(&self, n: usize, child: E) -> E
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()).