[][src]Struct mgf::Pool

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]

pub fn new() -> Self[src]

Create an empty Pool.

pub fn with_capacity(cap: usize) -> Self[src]

Create an empty Pool large enough to fix cap items.

pub fn empty(&self) -> bool[src]

Determines if the Pool is empty.

pub fn len(&self) -> usize[src]

Returns the number of occupied slots in the pool.

pub fn clear(&mut self)[src]

Removes all entries from the pool.

pub fn push(&mut self, item: T) -> usize[src]

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]

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]

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_mut<'a>(
    &'a mut self
) -> impl Iterator<Item = (usize, &'a mut T)>
[src]

pub fn get<'a>(&'a self, i: usize) -> Option<&'a T>[src]

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]

Returns a mutable reference to an object at the given index and None if it is unoccupied.

Trait Implementations

impl<L, T> From<L> for Pool<T> where
    L: IntoIterator<Item = T>, 
[src]

impl<T> Clone for Pool<T> where
    T: Clone
[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl<'a, T> IntoIterator for &'a Pool<T>[src]

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?

impl<'a, T> IntoIterator for &'a mut Pool<T>[src]

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?

impl<T> Index<usize> for Pool<T>[src]

type Output = T

The returned type after indexing.

impl<T> IndexMut<usize> for Pool<T>[src]

Auto Trait Implementations

impl<T> Send for Pool<T> where
    T: Send

impl<T> Sync for Pool<T> where
    T: Sync

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.