Struct mgf::Pool [−][src]
pub struct Pool<T> { /* fields omitted */ }
Growable array type that allows items to be removed and inserted without changing the indices of other entries.
Methods
impl<T> Pool<T>
[src]
impl<T> Pool<T>
pub fn new() -> Self
[src]
pub fn new() -> Self
Create an empty Pool.
pub fn with_capacity(cap: usize) -> Self
[src]
pub fn with_capacity(cap: usize) -> Self
Create an empty Pool large enough to fix cap items.
pub fn empty(&self) -> bool
[src]
pub fn empty(&self) -> bool
Determines if the Pool is empty.
pub fn len(&self) -> usize
[src]
pub fn len(&self) -> usize
Returns the number of occupied slots in the pool.
pub fn clear(&mut self)
[src]
pub fn clear(&mut self)
Removes all entries from the pool.
pub fn push(&mut self, item: T) -> usize
[src]
pub fn push(&mut self, item: T) -> usize
Push a new item to the pool. Attempts to use spots left empty from removed items before performing a heap allocation.
pub fn remove(&mut self, i: usize) -> T
[src]
pub fn remove(&mut self, i: usize) -> T
Marks an index as empty and adds it to the free list, allowing the spot to be reclaimed later.
pub fn next_free(&self) -> Option<usize>
[src]
pub fn next_free(&self) -> Option<usize>
Returns the next available id for reuse if one exists.
pub fn iter<'a>(
&'a self
) -> impl Iterator<Item = (usize, &'a T)>
[src]
pub fn iter<'a>(
&'a self
) -> impl Iterator<Item = (usize, &'a T)>
pub fn iter_mut<'a>(
&'a mut self
) -> impl Iterator<Item = (usize, &'a mut T)>
[src]
pub fn iter_mut<'a>(
&'a mut self
) -> impl Iterator<Item = (usize, &'a mut T)>
pub fn get<'a>(&'a self, i: usize) -> Option<&'a T>
[src]
pub fn get<'a>(&'a self, i: usize) -> Option<&'a T>
Returns a reference to an object at the given index and None if it is unoccupied.
pub fn get_mut<'a>(&'a mut self, i: usize) -> Option<&'a mut T>
[src]
pub fn get_mut<'a>(&'a mut self, i: usize) -> Option<&'a mut T>
Returns a mutable reference to an object at the given index and None if it is unoccupied.
Trait Implementations
impl<T> Index<usize> for Pool<T>
[src]
impl<T> Index<usize> for Pool<T>
type Output = T
The returned type after indexing.
fn index(&self, i: usize) -> &T
[src]
fn index(&self, i: usize) -> &T
Performs the indexing (container[index]
) operation.
impl<T> IndexMut<usize> for Pool<T>
[src]
impl<T> IndexMut<usize> for Pool<T>
fn index_mut(&mut self, i: usize) -> &mut T
[src]
fn index_mut(&mut self, i: usize) -> &mut T
Performs the mutable indexing (container[index]
) operation.
impl<T> Clone for Pool<T> where
T: Clone,
[src]
impl<T> Clone for Pool<T> where
T: Clone,
fn clone(&self) -> Self
[src]
fn clone(&self) -> Self
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<L, T> From<L> for Pool<T> where
L: IntoIterator<Item = T>,
[src]
impl<L, T> From<L> for Pool<T> where
L: IntoIterator<Item = T>,
impl<'a, T> IntoIterator for &'a Pool<T>
[src]
impl<'a, T> IntoIterator for &'a Pool<T>
type Item = (usize, &'a T)
The type of the elements being iterated over.
type IntoIter = FilterMap<Enumerate<Iter<'a, PoolEntry<T>>>, fn(_: (usize, &PoolEntry<T>)) -> Option<(usize, &T)>>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
fn into_iter(self) -> Self::IntoIter
Creates an iterator from a value. Read more
impl<'a, T> IntoIterator for &'a mut Pool<T>
[src]
impl<'a, T> IntoIterator for &'a mut Pool<T>
type Item = (usize, &'a mut T)
The type of the elements being iterated over.
type IntoIter = FilterMap<Enumerate<IterMut<'a, PoolEntry<T>>>, fn(_: (usize, &mut PoolEntry<T>)) -> Option<(usize, &mut T)>>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
fn into_iter(self) -> Self::IntoIter
Creates an iterator from a value. Read more