[][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<T> Clone for Pool<T> where
    T: Clone
[src]

impl<'de, T> Deserialize<'de> for Pool<T> where
    T: Deserialize<'de>, 
[src]

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

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

type Output = T

The returned type after indexing.

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

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> Serialize for Pool<T> where
    T: Serialize
[src]

Auto Trait Implementations

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

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

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

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

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

Blanket Implementations

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

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

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

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

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

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

type Owned = T

The resulting type after obtaining ownership.

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.