Trait generational_arena_tree::Node
source · pub trait Node: Debug + Sealed {
type Base: BaseNode;
type Token: NodeToken<Self>
where Self: Sized;
type Data;
type DataRef<'data>
where Self: 'data;
type DataRefMut<'data>
where Self: 'data;
// Required methods
fn new(arena: &mut Arena<Self::Base>, data: Self::Data) -> Self::Token
where Self: Sized;
fn token(&self) -> Self::Token
where Self: Sized;
fn parent(
&self
) -> Option<<<Self::Base as BaseNode>::Branch as Node>::Token>;
fn data(&self) -> Self::DataRef<'_>;
fn data_mut(&mut self) -> Self::DataRefMut<'_>;
// Provided methods
fn ancestors<'node>(
&'node self,
arena: &'node Arena<Self::Base>
) -> Ancestors<'node, Self::Base> ⓘ
where Self: Sized { ... }
fn root<'node>(
&'node self,
arena: &'node Arena<Self::Base>
) -> RootToken<Self>
where Self: Sized { ... }
}Expand description
A node in a tree.
Required Associated Types§
sourcetype Base: BaseNode
type Base: BaseNode
The ‘base node’ used in the arena.
For typed nodes where there is a typed node type in addition to separate branch and leaf
types, all of those types will use the typed node type as the ArenaNode.
sourcetype DataRefMut<'data>
where
Self: 'data
type DataRefMut<'data> where Self: 'data
Required Methods§
sourcefn new(arena: &mut Arena<Self::Base>, data: Self::Data) -> Self::Tokenwhere
Self: Sized,
fn new(arena: &mut Arena<Self::Base>, data: Self::Data) -> Self::Tokenwhere
Self: Sized,
Creates a new node allocated in the given arena using the given data.
The node’s token is returned.
sourcefn data_mut(&mut self) -> Self::DataRefMut<'_>
fn data_mut(&mut self) -> Self::DataRefMut<'_>
Returns a mutable reference to the data associated with this node.
Provided Methods§
sourcefn ancestors<'node>(
&'node self,
arena: &'node Arena<Self::Base>
) -> Ancestors<'node, Self::Base> ⓘwhere
Self: Sized,
fn ancestors<'node>(
&'node self,
arena: &'node Arena<Self::Base>
) -> Ancestors<'node, Self::Base> ⓘwhere
Self: Sized,
sourcefn root<'node>(&'node self, arena: &'node Arena<Self::Base>) -> RootToken<Self>where
Self: Sized,
fn root<'node>(&'node self, arena: &'node Arena<Self::Base>) -> RootToken<Self>where
Self: Sized,
Returns this node’s root node.
The root node is the most distant ancestor; it is the only node in a tree that does not have a parent.
If this node is the root node, RootToken::This is returned. Otherwise,
RootToken::Ancestor is returned with the root node’s token.
Internally, this method iterates over the node’s ancestors to find the last one, so it is
O(n) best, average, and worst case.
Object Safety§
Implementors§
source§impl<BranchData, LeafData> Node for SplitNode<BranchData, LeafData>
Available on crate feature split only.
impl<BranchData, LeafData> Node for SplitNode<BranchData, LeafData>
split only.type Base = SplitNode<BranchData, LeafData>
type Token = SplitToken<BranchData, LeafData>
type Data = SplitData<BranchData, LeafData>
type DataRef<'data> = SplitData<&'data BranchData, &'data LeafData> where Self: 'data
type DataRefMut<'data> = SplitData<&'data mut BranchData, &'data mut LeafData> where Self: 'data
source§impl<BranchData, LeafData> Node for SplitNodeDeque<BranchData, LeafData>
Available on crate features deque and split only.
impl<BranchData, LeafData> Node for SplitNodeDeque<BranchData, LeafData>
deque and split only.type Base = SplitNodeDeque<BranchData, LeafData>
type Token = SplitTokenDeque<BranchData, LeafData>
type Data = SplitData<BranchData, LeafData>
type DataRef<'data> = SplitData<&'data BranchData, &'data LeafData> where Self: 'data
type DataRefMut<'data> = SplitData<&'data mut BranchData, &'data mut LeafData> where Self: 'data
source§impl<BranchData, LeafData> Node for Branch<BranchData, LeafData>
Available on crate feature split only.
impl<BranchData, LeafData> Node for Branch<BranchData, LeafData>
split only.type Base = SplitNode<BranchData, LeafData>
type Token = Token<Branch<BranchData, LeafData>>
type Data = BranchData
type DataRef<'data> = &'data BranchData where Self: 'data
type DataRefMut<'data> = &'data mut BranchData where Self: 'data
source§impl<BranchData, LeafData> Node for BranchDeque<BranchData, LeafData>
Available on crate features deque and split only.
impl<BranchData, LeafData> Node for BranchDeque<BranchData, LeafData>
deque and split only.type Base = SplitNodeDeque<BranchData, LeafData>
type Token = Token<BranchDeque<BranchData, LeafData>>
type Data = BranchData
type DataRef<'data> = &'data BranchData where Self: 'data
type DataRefMut<'data> = &'data mut BranchData where Self: 'data
source§impl<BranchData, LeafData> Node for Leaf<BranchData, LeafData>
Available on crate feature split only.
impl<BranchData, LeafData> Node for Leaf<BranchData, LeafData>
split only.type Base = SplitNode<BranchData, LeafData>
type Token = Token<Leaf<BranchData, LeafData>>
type Data = LeafData
type DataRef<'data> = &'data LeafData where Self: 'data
type DataRefMut<'data> = &'data mut LeafData where Self: 'data
source§impl<BranchData, LeafData> Node for LeafDeque<BranchData, LeafData>
Available on crate features deque and split only.
impl<BranchData, LeafData> Node for LeafDeque<BranchData, LeafData>
deque and split only.type Base = SplitNodeDeque<BranchData, LeafData>
type Token = Token<LeafDeque<BranchData, LeafData>>
type Data = LeafData
type DataRef<'data> = &'data LeafData where Self: 'data
type DataRefMut<'data> = &'data mut LeafData where Self: 'data
source§impl<Data: Debug> Node for UnifiedNode<Data>
Available on crate feature unified only.
impl<Data: Debug> Node for UnifiedNode<Data>
unified only.type Base = UnifiedNode<Data>
type Token = Token<UnifiedNode<Data>>
type Data = Data
type DataRef<'data> = &'data Data where Self: 'data
type DataRefMut<'data> = &'data mut Data where Self: 'data
source§impl<Data: Debug> Node for UnifiedNodeDeque<Data>
Available on crate feature unified only.
impl<Data: Debug> Node for UnifiedNodeDeque<Data>
unified only.