Enum arenatree::Arena [−][src]
Arenas are efficient ways of storing trees: All nodes are actually on a flat surface, but have IDs to other nodes.
Variants
Owned(Vec<Option<T>>)
Borrowed(&'a mut Vec<Option<T>>)
Methods
impl<'a, T> Arena<'a, T>
[src]
impl<'a, T> Arena<'a, T>
pub fn new() -> Self
[src]
pub fn new() -> Self
Create a new arena instance
pub fn with_arena(arena: &'a mut Vec<Option<T>>) -> Self
[src]
pub fn with_arena(arena: &'a mut Vec<Option<T>>) -> Self
Create a new arena instance that reuses an existing vector
pub fn reference<'b>(&'b mut self) -> Arena<'b, T>
[src]
pub fn reference<'b>(&'b mut self) -> Arena<'b, T>
Create a new arena reference that shares the inner vector. This reference will make the existing instance invalid for use while the reference is active.
pub fn into_inner(self) -> Vec<Option<T>>
[src]
pub fn into_inner(self) -> Vec<Option<T>>
pub fn get_ref(&self) -> &[Option<T>]
[src]
pub fn get_ref(&self) -> &[Option<T>]
Return a slice pointing to the inner arena representation
ⓘImportant traits for ArenaIter<'a, T>pub fn iter(&self) -> ArenaIter<T>
[src]
pub fn iter(&self) -> ArenaIter<T>
Return an iterator over the nodes in this arena
pub fn insert(&mut self, elem: T) -> NodeId
[src]
pub fn insert(&mut self, elem: T) -> NodeId
Place an element into the arena
pub fn take(&mut self, index: NodeId) -> T
[src]
pub fn take(&mut self, index: NodeId) -> T
Move out of an element in the arena. This will make following indexing calls on that index panic. This will not deallocate any space. This is due to the fact that all indexes need to stay the same. We could use a different data type instead of a tree to prevent this, but that instead means lookup will be slightly slower.
Trait Implementations
impl<'a, T: Debug + 'a> Debug for Arena<'a, T>
[src]
impl<'a, T: Debug + 'a> Debug for Arena<'a, T>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<'a, T> Default for Arena<'a, T>
[src]
impl<'a, T> Default for Arena<'a, T>
impl<'a, T> Index<NodeId> for Arena<'a, T>
[src]
impl<'a, T> Index<NodeId> for Arena<'a, T>
type Output = T
The returned type after indexing.
fn index(&self, index: NodeId) -> &Self::Output
[src]
fn index(&self, index: NodeId) -> &Self::Output
Performs the indexing (container[index]
) operation.
impl<'a, T> IndexMut<NodeId> for Arena<'a, T>
[src]
impl<'a, T> IndexMut<NodeId> for Arena<'a, T>
fn index_mut(&mut self, index: NodeId) -> &mut Self::Output
[src]
fn index_mut(&mut self, index: NodeId) -> &mut Self::Output
Performs the mutable indexing (container[index]
) operation.
impl<'r, 'a, T> IntoIterator for &'r Arena<'a, T>
[src]
impl<'r, 'a, T> IntoIterator for &'r Arena<'a, T>