Struct id_map::IdMap
[−]
[src]
pub struct IdMap<T> { /* fields omitted */ }
A container that gives each item a unique id. Internally all elements are stored contiguously.
Methods
impl<T> IdMap<T>
[src]
fn new() -> Self
[src]
Creates an empty IdMap<T>
.
fn with_capacity(cap: usize) -> Self
[src]
Creates an IdMap<T>
with the specified capacity.
fn clear(&mut self)
[src]
Removes all values from the map.
fn next_id(&self) -> Id
[src]
Returns the id that a subsequent call to insert() will produce.
fn len(&self) -> usize
[src]
Returns the number of id-value pairs in the map.
fn capacity(&self) -> usize
[src]
Returns the number of id-value pairs the map can hold before reallocating.
fn reserve(&mut self, cap: usize)
[src]
Resizes the map such that that capacity() >= cap
.
fn shrink_to_fit(&mut self)
[src]
Resizes the map to minimize allocated memory.
fn as_set(&self) -> &IdSet
[src]
Returns a reference to the set of valid ids.
fn insert(&mut self, val: T) -> Id
[src]
Inserts a value into an empty slot in the map and returns its id.
fn insert_at(&mut self, id: Id, val: T) -> Option<T>
[src]
Inserts a value at a specific id, returning the old value if it existed.
fn remove(&mut self, id: Id) -> Option<T>
[src]
Removes an id from the map, returning its value if it was previously in the map.
fn get_or_insert(&mut self, id: Id, val: T) -> &mut T
[src]
If the id has a value, returns it, otherwise inserts a new value.
fn get_or_insert_with<F: FnOnce() -> T>(&mut self, id: Id, f: F) -> &mut T
[src]
If the id has a value, returns it, otherwise inserts a new value with the provided closure.
fn remove_set(&mut self, set: &IdSet)
[src]
Removes all ids in the set from the map.
fn retain<F: FnMut(Id, &T) -> bool>(&mut self, pred: F)
[src]
Remove all values not satisfying the predicate.
fn contains(&self, id: Id) -> bool
[src]
Returns true if the map contains a value for the specified id.
fn get(&self, id: Id) -> Option<&T>
[src]
Returns a reference to the value at the specified id if it is in the map.
fn get_mut(&mut self, id: Id) -> Option<&mut T>
[src]
Returns a mutable reference to the value at the specified id if it is in the map.
fn ids(&self) -> Ids
[src]
An iterator over ids, in increasing order.
fn values(&self) -> Values<T>
[src]
An iterator over values, in order of increasing id.
fn values_mut(&mut self) -> ValuesMut<T>
[src]
A mutable iterator over values, in order of increasing id.
fn iter(&self) -> Iter<T>
[src]
An iterator over id-value pairs, in order of increasing id.
fn iter_mut(&mut self) -> IterMut<T>
[src]
A mutable iterator over id-value pairs, in order of increasing id.
fn into_iter(self) -> IntoIter<T>
[src]
A consuming iterator over id-value pairs, in order of increasing id.
Trait Implementations
impl<T> Drop for IdMap<T>
[src]
impl<T: Clone> Clone for IdMap<T>
[src]
fn clone(&self) -> Self
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, other: &Self)
[src]
Performs copy-assignment from source
. Read more
impl<T: Debug> Debug for IdMap<T>
[src]
impl<T> Default for IdMap<T>
[src]
impl<T: Eq> Eq for IdMap<T>
[src]
impl<T: PartialEq> PartialEq for IdMap<T>
[src]
fn eq(&self, other: &Self) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<T> Extend<T> for IdMap<T>
[src]
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
[src]
Extends a collection with the contents of an iterator. Read more
impl<T> FromIterator<T> for IdMap<T>
[src]
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
[src]
Creates a value from an iterator. Read more
impl<T> FromIterator<(Id, T)> for IdMap<T>
[src]
fn from_iter<I: IntoIterator<Item = (Id, T)>>(iter: I) -> Self
[src]
Creates a value from an iterator. Read more
impl<'a, T> IntoIterator for &'a IdMap<T>
[src]
type Item = (Id, &'a T)
The type of the elements being iterated over.
type IntoIter = Iter<'a, T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
Creates an iterator from a value. Read more
impl<'a, T> IntoIterator for &'a mut IdMap<T>
[src]
type Item = (Id, &'a mut T)
The type of the elements being iterated over.
type IntoIter = IterMut<'a, T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
Creates an iterator from a value. Read more
impl<T> IntoIterator for IdMap<T>
[src]
type Item = (Id, T)
The type of the elements being iterated over.
type IntoIter = IntoIter<T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
Creates an iterator from a value. Read more
impl<T> Index<Id> for IdMap<T>
[src]
type Output = T
The returned type after indexing.
fn index(&self, id: Id) -> &Self::Output
[src]
Performs the indexing (container[index]
) operation.