Trait generational_arena_tree::BranchNode
source · pub trait BranchNode: Node {
type ChildrenIter<'branch>: DoubleEndedIterator<Item = <Self::Base as Node>::Token> + FusedIterator
where Self: 'branch;
// Required methods
fn first(&self) -> Option<<Self::Base as Node>::Token>;
fn last(&self) -> Option<<Self::Base as Node>::Token>;
fn children<'branch>(
&'branch self,
arena: &'branch Arena<Self::Base>
) -> Self::ChildrenIter<'branch>;
fn is_empty(&self) -> bool;
fn detach_front(
token: Self::Token,
arena: &mut Arena<Self::Base>
) -> Option<<Self::Base as Node>::Token>
where Self: Sized,
for<'base> &'base mut Self: TryFrom<&'base mut Self::Base>,
for<'base> <&'base mut Self as TryFrom<&'base mut Self::Base>>::Error: Debug;
fn detach_back(
token: Self::Token,
arena: &mut Arena<Self::Base>
) -> Option<<Self::Base as Node>::Token>
where Self: Sized,
for<'base> &'base mut Self: TryFrom<&'base mut Self::Base>,
for<'base> <&'base mut Self as TryFrom<&'base mut Self::Base>>::Error: Debug;
fn pop_front(
token: Self::Token,
arena: &mut Arena<Self::Base>
) -> Option<<Self::Base as BaseNode>::Representation>
where Self: Sized,
for<'base> &'base mut Self: TryFrom<&'base mut Self::Base>,
for<'base> <&'base mut Self as TryFrom<&'base mut Self::Base>>::Error: Debug;
fn pop_back(
token: Self::Token,
arena: &mut Arena<Self::Base>
) -> Option<<Self::Base as BaseNode>::Representation>
where Self: Sized,
for<'base> &'base mut Self: TryFrom<&'base mut Self::Base>,
for<'base> <&'base mut Self as TryFrom<&'base mut Self::Base>>::Error: Debug;
fn push_front(
token: Self::Token,
arena: &mut Arena<Self::Base>,
new: <Self::Base as Node>::Token
)
where Self: Sized,
for<'base> &'base mut Self: TryFrom<&'base mut Self::Base>,
for<'base> <&'base mut Self as TryFrom<&'base mut Self::Base>>::Error: Debug;
fn push_back(
token: Self::Token,
arena: &mut Arena<Self::Base>,
new: <Self::Base as Node>::Token
)
where Self: Sized,
for<'base> &'base mut Self: TryFrom<&'base mut Self::Base>,
for<'base> <&'base mut Self as TryFrom<&'base mut Self::Base>>::Error: Debug;
// Provided method
fn descendants<'branch>(
&'branch self,
arena: &'branch Arena<Self::Base>
) -> Descendants<'branch, Self> ⓘ
where Self: Sized,
for<'base> &'base Self: TryFrom<&'base Self::Base> { ... }
}
Required Associated Types§
sourcetype ChildrenIter<'branch>: DoubleEndedIterator<Item = <Self::Base as Node>::Token> + FusedIterator
where
Self: 'branch
type ChildrenIter<'branch>: DoubleEndedIterator<Item = <Self::Base as Node>::Token> + FusedIterator where Self: 'branch
The iterator returned by children
.
Required Methods§
sourcefn children<'branch>(
&'branch self,
arena: &'branch Arena<Self::Base>
) -> Self::ChildrenIter<'branch>
fn children<'branch>( &'branch self, arena: &'branch Arena<Self::Base> ) -> Self::ChildrenIter<'branch>
Returns an iterator over the tokens of this branch node’s children.
sourcefn detach_front(
token: Self::Token,
arena: &mut Arena<Self::Base>
) -> Option<<Self::Base as Node>::Token>where
Self: Sized,
for<'base> &'base mut Self: TryFrom<&'base mut Self::Base>,
for<'base> <&'base mut Self as TryFrom<&'base mut Self::Base>>::Error: Debug,
fn detach_front(
token: Self::Token,
arena: &mut Arena<Self::Base>
) -> Option<<Self::Base as Node>::Token>where
Self: Sized,
for<'base> &'base mut Self: TryFrom<&'base mut Self::Base>,
for<'base> <&'base mut Self as TryFrom<&'base mut Self::Base>>::Error: Debug,
Detaches this branch node’s first child, returning its token.
If this branch node is empty then there is no child to detach, so None
is
returned. Otherwise, the child is removed from this branch node’s children, but
remains in the arena.
This function is useful if you want to move a node from one parent to another.
This function takes its token as a parameter instead of &mut self
as a receiver to
avoid having multiple mutable references into the arena at a time.
See also
The last child may also be detached using detach_back
.
If this is a BranchNodeDeque
, children may also be detached by index using
detach
.
If you want to remove a child and its descendants from the arena altogether, see
pop_front
, pop_back
, or, if this is a BranchNodeDeque
, remove
.
sourcefn detach_back(
token: Self::Token,
arena: &mut Arena<Self::Base>
) -> Option<<Self::Base as Node>::Token>where
Self: Sized,
for<'base> &'base mut Self: TryFrom<&'base mut Self::Base>,
for<'base> <&'base mut Self as TryFrom<&'base mut Self::Base>>::Error: Debug,
fn detach_back(
token: Self::Token,
arena: &mut Arena<Self::Base>
) -> Option<<Self::Base as Node>::Token>where
Self: Sized,
for<'base> &'base mut Self: TryFrom<&'base mut Self::Base>,
for<'base> <&'base mut Self as TryFrom<&'base mut Self::Base>>::Error: Debug,
Detaches this branch node’s last child, returning its token.
If this branch node is empty then there is no child to detach, so None
is
returned. Otherwise, the child is removed from this branch node’s children, but
remains in the arena.
This function is useful if you want to move a node from one parent to another.
This function takes its token as a parameter instead of &mut self
as a receiver to
avoid having multiple mutable references into the arena at a time.
See also
The first child may also be detached using detach_front
.
If this is a BranchNodeDeque
, children may also be detached by index using
detach
.
If you want to remove a child and its descendants from the arena altogether, see
pop_front
, pop_back
, or, if this is a BranchNodeDeque
, remove
.
sourcefn pop_front(
token: Self::Token,
arena: &mut Arena<Self::Base>
) -> Option<<Self::Base as BaseNode>::Representation>where
Self: Sized,
for<'base> &'base mut Self: TryFrom<&'base mut Self::Base>,
for<'base> <&'base mut Self as TryFrom<&'base mut Self::Base>>::Error: Debug,
fn pop_front(
token: Self::Token,
arena: &mut Arena<Self::Base>
) -> Option<<Self::Base as BaseNode>::Representation>where
Self: Sized,
for<'base> &'base mut Self: TryFrom<&'base mut Self::Base>,
for<'base> <&'base mut Self as TryFrom<&'base mut Self::Base>>::Error: Debug,
Removes this branch node’s first child.
If this branch node is empty then there is no child to remove, so None
is
returned. Otherwise, the removed node is returned.
This function takes its token as a parameter instead of &mut self
as a receiver to
avoid having multiple mutable references into the arena at a time.
See also
The last child may also be removed using pop_back
.
If this is a BranchNodeDeque
, children may also be removed by index using
remove
.
If you don’t want to remove a child from the arena, but merely make it a root node
or move it to another parent, see
detach_front
, detach_back
, or, if this is a BranchNodeDeque
, detach
.
sourcefn pop_back(
token: Self::Token,
arena: &mut Arena<Self::Base>
) -> Option<<Self::Base as BaseNode>::Representation>where
Self: Sized,
for<'base> &'base mut Self: TryFrom<&'base mut Self::Base>,
for<'base> <&'base mut Self as TryFrom<&'base mut Self::Base>>::Error: Debug,
fn pop_back(
token: Self::Token,
arena: &mut Arena<Self::Base>
) -> Option<<Self::Base as BaseNode>::Representation>where
Self: Sized,
for<'base> &'base mut Self: TryFrom<&'base mut Self::Base>,
for<'base> <&'base mut Self as TryFrom<&'base mut Self::Base>>::Error: Debug,
Removes this branch node’s last child.
If this branch node is empty then there is no child to remove, so None
is
returned. Otherwise, the removed node is returned.
This function takes its token as a parameter instead of &mut self
as a receiver
avoid having multiple mutable references into the arena at a time.
See also
The first child may also be removed using pop_front
.
If this is a BranchNodeDeque
, children may also be removed by index using
remove
.
If you don’t want to remove a child from the arena, but merely make it a root node
or move it to another parent, see
detach_front
, detach_back
, or, if this is a BranchNodeDeque
, detach
.
sourcefn push_front(
token: Self::Token,
arena: &mut Arena<Self::Base>,
new: <Self::Base as Node>::Token
)where
Self: Sized,
for<'base> &'base mut Self: TryFrom<&'base mut Self::Base>,
for<'base> <&'base mut Self as TryFrom<&'base mut Self::Base>>::Error: Debug,
fn push_front(
token: Self::Token,
arena: &mut Arena<Self::Base>,
new: <Self::Base as Node>::Token
)where
Self: Sized,
for<'base> &'base mut Self: TryFrom<&'base mut Self::Base>,
for<'base> <&'base mut Self as TryFrom<&'base mut Self::Base>>::Error: Debug,
Pushes the given new
token’s node to the beginning of this branch node’s
children.
This function takes its token as a parameter instead of &mut self
as a receiver to
avoid having multiple mutable references into the arena at a time.
Panics
This method will panic if the given new
token refers to either:
See also
A child may also be pushed to the end with push_back
.
If this is a BranchNodeDeque
, children may also be inserted by index using
insert
.
sourcefn push_back(
token: Self::Token,
arena: &mut Arena<Self::Base>,
new: <Self::Base as Node>::Token
)where
Self: Sized,
for<'base> &'base mut Self: TryFrom<&'base mut Self::Base>,
for<'base> <&'base mut Self as TryFrom<&'base mut Self::Base>>::Error: Debug,
fn push_back(
token: Self::Token,
arena: &mut Arena<Self::Base>,
new: <Self::Base as Node>::Token
)where
Self: Sized,
for<'base> &'base mut Self: TryFrom<&'base mut Self::Base>,
for<'base> <&'base mut Self as TryFrom<&'base mut Self::Base>>::Error: Debug,
Pushes the given new
token’s node to the end of this branch node’s children.
This function takes its token as a parameter instead of &mut self
as a receiver to
avoid having multiple mutable references into the arena at a time.
Panics
This method will panic if the given new
token refers to either:
See also
A child may also be pushed to the beginning with push_front
. If this is a
BranchNodeDeque
, children may also be inserted by index using insert
.
If this is a BranchNodeDeque
, children may also be inserted by index using
insert
.
Provided Methods§
sourcefn descendants<'branch>(
&'branch self,
arena: &'branch Arena<Self::Base>
) -> Descendants<'branch, Self> ⓘ
fn descendants<'branch>( &'branch self, arena: &'branch Arena<Self::Base> ) -> Descendants<'branch, Self> ⓘ
Object Safety§
Implementors§
source§impl<BranchData, LeafData> BranchNode for Branch<BranchData, LeafData>
Available on crate feature split
only.
impl<BranchData, LeafData> BranchNode for Branch<BranchData, LeafData>
split
only.type ChildrenIter<'branch> = ChildrenLinked<'branch, Branch<BranchData, LeafData>> where Self: 'branch
source§impl<Data: Debug> BranchNode for UnifiedNode<Data>
Available on crate feature unified
only.
impl<Data: Debug> BranchNode for UnifiedNode<Data>
unified
only.type ChildrenIter<'branch> = ChildrenLinked<'branch, UnifiedNode<Data>> where Self: 'branch
source§impl<Data: Debug> BranchNode for UnifiedNodeDeque<Data>
Available on crate feature unified
only.
impl<Data: Debug> BranchNode for UnifiedNodeDeque<Data>
unified
only.