Struct synctree::arena::Arena [−][src]
pub struct Arena<T> { /* fields omitted */ }
A map, providing fast indexing, insertion and removal of elements, but not preserving element order.
Every element is associated with a unique id.
Inside, it uses a fast FnvHashSet
with free ids.
Every time an element is removed, it's id is being written there, so there is no need to shift other elements to the empty space.
Methods
impl<T> Arena<T>
[src]
impl<T> Arena<T>
pub fn new() -> Arena<T>
[src]
pub fn new() -> Arena<T>
Constructs an empty Arena
.
The arena won't allocate until elements are pushed onto it.
pub fn with_capacity(capacity: usize) -> Arena<T>
[src]
pub fn with_capacity(capacity: usize) -> Arena<T>
Constructs a new Arena
with specified capacity. If capacity
is 0
, the arena won't allocate.
pub fn capacity(&self) -> usize
[src]
pub fn capacity(&self) -> usize
Returns the capacity of Arena
.
pub fn len(&self) -> usize
[src]
pub fn len(&self) -> usize
Returns the number of elements in Arena
.
pub fn is_empty(&self) -> bool
[src]
pub fn is_empty(&self) -> bool
Returns true if the arena contains no elements.
pub fn insert(&mut self, element: T) -> Id
[src]
pub fn insert(&mut self, element: T) -> Id
Inserts a new element into the arena and returns an id associated with it.
pub fn contains(&self, id: Id) -> bool
[src]
pub fn contains(&self, id: Id) -> bool
Returns true if the arena contains given id.
pub fn get(&self, id: Id) -> Option<&T>
[src]
pub fn get(&self, id: Id) -> Option<&T>
Returns a reference to an element in the arena.
If the specified id does not exists, returns None
.
pub fn get_mut(&mut self, id: Id) -> Option<&mut T>
[src]
pub fn get_mut(&mut self, id: Id) -> Option<&mut T>
Returns a mutable reference to an element in the arena.
If the specified id does not exists, returns None
.
pub fn remove(&mut self, id: Id) -> Option<T>
[src]
pub fn remove(&mut self, id: Id) -> Option<T>
Removes and returns the element with specified id.
If the id does not exists, returns None
.
pub fn clear(&mut self)
[src]
pub fn clear(&mut self)
Clears the arena.
This method does not change the capacity of the arena.
ⓘImportant traits for Iter<'a, T>pub fn iter<'a>(&'a self) -> Iter<'a, T>
[src]
pub fn iter<'a>(&'a self) -> Iter<'a, T>
Returns an iterator over the arena.
ⓘImportant traits for IterMut<'a, T>pub fn iter_mut<'a>(&'a mut self) -> IterMut<'a, T>
[src]
pub fn iter_mut<'a>(&'a mut self) -> IterMut<'a, T>
Returns a mutable iterator over the arena.
Trait Implementations
impl<T: Debug> Debug for Arena<T>
[src]
impl<T: Debug> Debug for Arena<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<T: Clone> Clone for Arena<T>
[src]
impl<T: Clone> Clone for Arena<T>
fn clone(&self) -> Arena<T>
[src]
fn clone(&self) -> Arena<T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<T> Index<Id> for Arena<T>
[src]
impl<T> Index<Id> for Arena<T>
type Output = T
The returned type after indexing.
fn index(&self, index: Id) -> &T
[src]
fn index(&self, index: Id) -> &T
Performs the indexing (container[index]
) operation.
impl<T> IndexMut<Id> for Arena<T>
[src]
impl<T> IndexMut<Id> for Arena<T>