pub trait BranchNodeDeque: BranchNode
where Self: Index<usize, Output = <Self::Base as Node>::Token> + Sized,
{ // Required methods fn len(&self) -> usize; fn detach( token: Self::Token, arena: &mut Arena<Self::Base>, index: usize ) -> <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 remove( token: Self::Token, arena: &mut Arena<Self::Base>, index: usize ) -> <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 insert( token: Self::Token, arena: &mut Arena<Self::Base>, index: usize, 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 get(&self, index: usize) -> Option<<Self::Base as Node>::Token> { ... } }
Available on crate feature deque only.
Expand description

A node that stores its children as a VecDeque, allowing them to be indexed.

Required Methods§

source

fn len(&self) -> usize

Returns the number of children this branch node has.

source

fn detach( token: Self::Token, arena: &mut Arena<Self::Base>, index: usize ) -> <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 the child at the given index, returning its token.

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.

Panics

This method will panic if the given index is out of bounds.

See also

The first child or last child may be detached with detach_front and detach_back respectively.

If you want to remove a child and its descendents from the arena altogether, see remove, pop_front, or pop_back.

source

fn remove( token: Self::Token, arena: &mut Arena<Self::Base>, index: usize ) -> <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 the child at the given index.

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 index is out of bounds.

See also

The first child or last child may be removed with pop_front and pop_back respectively.

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, detach_front, or detach_back.

source

fn insert( token: Self::Token, arena: &mut Arena<Self::Base>, index: usize, 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,

Inserts the given new token’s node at the given index.

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 index is greater than the len(); or
  • the given new token refers to either:
See also

A child can also be pushed to the beginning or end of this branch node’s children with push_front and push_back respectively.

Provided Methods§

source

fn get(&self, index: usize) -> Option<<Self::Base as Node>::Token>

Returns the token of the child at the given index.

If index is out of bounds, None is returned.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<Data: Debug> BranchNodeDeque for UnifiedNodeDeque<Data>

Available on crate feature unified only.