Struct slab::Slab
[−]
[src]
pub struct Slab<T, I = usize> { /* fields omitted */ }
A preallocated chunk of memory for storing objects of the same type.
Methods
impl<T, I> Slab<T, I>
[src]
fn with_capacity(capacity: usize) -> Slab<T, I>
Returns an empty Slab
with the requested capacity
fn len(&self) -> usize
Returns the number of values stored by the Slab
fn capacity(&self) -> usize
Returns the total capacity of the Slab
fn is_empty(&self) -> bool
Returns true if the Slab
is storing no values
fn available(&self) -> usize
Returns the number of available slots remaining in the Slab
fn has_available(&self) -> bool
Returns true if the Slab
has available slots
impl<T, I: Into<usize> + From<usize>> Slab<T, I>
[src]
fn contains(&self, idx: I) -> bool
Returns true if the Slab
contains a value for the given token
fn get(&self, idx: I) -> Option<&T>
Get a reference to the value associated with the given token
fn get_mut(&mut self, idx: I) -> Option<&mut T>
Get a mutable reference to the value associated with the given token
fn insert(&mut self, val: T) -> Result<I, T>
Insert a value into the slab, returning the associated token
fn entry(&mut self, idx: I) -> Option<Entry<T, I>>
Returns a handle to an entry.
This allows more advanced manipulation of the value stored at the given index.
fn vacant_entry(&mut self) -> Option<VacantEntry<T, I>>
Returns a handle to a vacant entry.
This allows optionally inserting a value that is constructed with the index.
fn remove(&mut self, idx: I) -> Option<T>
Releases the given slot
fn retain<F>(&mut self, f: F) where F: FnMut(&T) -> bool
Retain only the elements specified by the predicate.
In other words, remove all elements e
such that f(&e)
returns false.
This method operates in place and preserves the order of the retained
elements.
fn iter(&self) -> Iter<T, I>
An iterator for visiting all elements stored in the Slab
fn iter_mut(&mut self) -> IterMut<T, I>
A mutable iterator for visiting all elements stored in the Slab
fn clear(&mut self)
Empty the slab, by freeing all entries
fn reserve_exact(&mut self, additional: usize)
Reserves the minimum capacity for exactly additional
more elements to
be inserted in the given Slab
. Does nothing if the capacity is
already sufficient.
Trait Implementations
impl<T, I> Send for Slab<T, I> where T: Send
[src]
impl<T, I: From<usize> + Into<usize>> Index<I> for Slab<T, I>
[src]
type Output = T
The returned type after indexing
fn index(&self, index: I) -> &T
The method for the indexing (container[index]
) operation
impl<T, I: From<usize> + Into<usize>> IndexMut<I> for Slab<T, I>
[src]
fn index_mut(&mut self, index: I) -> &mut T
The method for the mutable indexing (container[index]
) operation
impl<T, I> Debug for Slab<T, I> where T: Debug, I: Debug
[src]
impl<'a, T, I: From<usize> + Into<usize>> IntoIterator for &'a Slab<T, I>
[src]
type Item = &'a T
The type of the elements being iterated over.
type IntoIter = Iter<'a, T, I>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Iter<'a, T, I>
Creates an iterator from a value. Read more