Struct sid::IdVec [−][src]
pub struct IdVec<ID: Identifier, T> { /* fields omitted */ }
Similar to Vec except that it is indexed using an Id rather than an usize index. if the stored type implements Default, IdVec can also use the set(...) method which can grow the vector to accomodate for the requested id.
Methods
impl<ID: Identifier, T> IdVec<ID, T>[src]
impl<ID: Identifier, T> IdVec<ID, T>pub fn new() -> Self[src]
pub fn new() -> SelfCreate an empty IdVec
pub fn with_capacity(size: ID::Handle) -> Self[src]
pub fn with_capacity(size: ID::Handle) -> SelfCreate an IdVec with preallocated storage
pub fn from_vec(vec: Vec<T>) -> Self[src]
pub fn from_vec(vec: Vec<T>) -> SelfCreate an IdVec by recycling a Vec and its content.
pub fn into_vec(self) -> Vec<T>[src]
pub fn into_vec(self) -> Vec<T>Consume the IdVec and create a Vec.
pub fn as_vec(&self) -> &Vec<T>[src]
pub fn as_vec(&self) -> &Vec<T>Exposes the internal Vec.
pub fn len(&self) -> ID::Handle[src]
pub fn len(&self) -> ID::HandleNumber of elements in the IdVec
pub fn is_empty(&self) -> bool[src]
pub fn is_empty(&self) -> boolReturns true if the vector contains no elements.
pub fn as_slice(&self) -> IdSlice<ID, T>[src]
pub fn as_slice(&self) -> IdSlice<ID, T>Extracts a slice containing the entire vector.
pub fn as_mut_slice(&mut self) -> MutIdSlice<ID, T>[src]
pub fn as_mut_slice(&mut self) -> MutIdSlice<ID, T>Extracts a mutable slice containing the entire vector.
pub fn range(&self, ids: IdRange<ID::Tag, ID::Handle>) -> IdSlice<ID, T>[src]
pub fn range(&self, ids: IdRange<ID::Tag, ID::Handle>) -> IdSlice<ID, T>pub fn mut_range(
&mut self,
ids: IdRange<ID::Tag, ID::Handle>
) -> MutIdSlice<ID, T>[src]
pub fn mut_range(
&mut self,
ids: IdRange<ID::Tag, ID::Handle>
) -> MutIdSlice<ID, T>pub fn range_from(&self, id: ID) -> IdSlice<ID, T>[src]
pub fn range_from(&self, id: ID) -> IdSlice<ID, T>pub fn mut_range_from(&mut self, id: ID) -> MutIdSlice<ID, T>[src]
pub fn mut_range_from(&mut self, id: ID) -> MutIdSlice<ID, T>pub fn range_to(&self, id: ID) -> IdSlice<ID, T>[src]
pub fn range_to(&self, id: ID) -> IdSlice<ID, T>pub fn mut_range_to(&mut self, id: ID) -> MutIdSlice<ID, T>[src]
pub fn mut_range_to(&mut self, id: ID) -> MutIdSlice<ID, T>pub fn range_to_inclusive(&self, id: ID) -> IdSlice<ID, T>[src]
pub fn range_to_inclusive(&self, id: ID) -> IdSlice<ID, T>pub fn mut_range_to_inclusive(&mut self, id: ID) -> MutIdSlice<ID, T>[src]
pub fn mut_range_to_inclusive(&mut self, id: ID) -> MutIdSlice<ID, T>pub fn nth(&self, idx: ID::Handle) -> &T[src]
pub fn nth(&self, idx: ID::Handle) -> &TReturn the nth element of the IdVec using an usize index rather than an Id (à la Vec).
pub fn nth_mut(&mut self, idx: ID::Handle) -> &mut T[src]
pub fn nth_mut(&mut self, idx: ID::Handle) -> &mut TReturn the nth element of the IdVec using an usize index rather than an Id (à la Vec).
pub fn iter<'l>(&'l self) -> Iter<'l, T>[src]
pub fn iter<'l>(&'l self) -> Iter<'l, T>Iterate over the elements of the IdVec
pub fn iter_mut<'l>(&'l mut self) -> IterMut<'l, T>[src]
pub fn iter_mut<'l>(&'l mut self) -> IterMut<'l, T>Iterate over the elements of the IdVec
pub fn push(&mut self, elt: T) -> ID[src]
pub fn push(&mut self, elt: T) -> IDAdd an element to the IdVec and return its Id. This method can cause the storage to be reallocated.
pub fn insert(&mut self, id: ID, elt: T)[src]
pub fn insert(&mut self, id: ID, elt: T)Inserts an element at position id within the vector, shifting all elements
after it to the right.
pub fn insert_slice(&mut self, id: ID, elts: &[T]) where
T: Clone, [src]
pub fn insert_slice(&mut self, id: ID, elts: &[T]) where
T: Clone, Insert several elements by cloning them starting at position 'id` and shifting all elements after them to the right.
pub fn insert_id_slice(&mut self, id: ID, elts: IdSlice<ID, T>) where
T: Clone, [src]
pub fn insert_id_slice(&mut self, id: ID, elts: IdSlice<ID, T>) where
T: Clone, Insert several elements by cloning them starting at position 'id` and shifting all elements after them to the right.
pub fn extend_from_slice(&mut self, elts: &[T]) where
T: Clone, [src]
pub fn extend_from_slice(&mut self, elts: &[T]) where
T: Clone, Clones and appends all elements in a slice to the vector.
pub fn extend_from_id_slice(&mut self, elts: IdSlice<ID, T>) where
T: Clone, [src]
pub fn extend_from_id_slice(&mut self, elts: IdSlice<ID, T>) where
T: Clone, Clones and appends all elements in a slice to the vector.
pub fn reserve(&mut self, additional: ID::Handle)[src]
pub fn reserve(&mut self, additional: ID::Handle)Reserves capacity for at least additional more elements to be inserted in the given vector.
pub fn shrink_to_fit(&mut self)[src]
pub fn shrink_to_fit(&mut self)Shrinks the capacity of the vector as much as possible.
pub fn clear(&mut self)[src]
pub fn clear(&mut self)Drop all of the contained elements and clear the IdVec's storage.
pub fn remove(&mut self, index: ID) -> T[src]
pub fn remove(&mut self, index: ID) -> TRemoves and returns the element at position index within the vector, shifting all elements after it to the left.
pub fn swap_remove(&mut self, index: ID) -> T[src]
pub fn swap_remove(&mut self, index: ID) -> TRemoves an element from the vector and returns it. The removed element is replaced by the last element of the vector.
pub fn has_id(&self, id: ID) -> bool[src]
pub fn has_id(&self, id: ID) -> boolpub fn first_id(&self) -> Option<ID>[src]
pub fn first_id(&self) -> Option<ID>pub fn last_id(&self) -> Option<ID>[src]
pub fn last_id(&self) -> Option<ID>ⓘImportant traits for IdRange<T, H>pub fn ids(&self) -> IdRange<ID::Tag, ID::Handle>[src]
pub fn ids(&self) -> IdRange<ID::Tag, ID::Handle>impl<ID: Identifier, T: Default> IdVec<ID, T>[src]
impl<ID: Identifier, T: Default> IdVec<ID, T>pub fn set(&mut self, id: ID, val: T)[src]
pub fn set(&mut self, id: ID, val: T)Set the value for a certain Id, possibly adding default values if the Id's index is Greater than the size of the underlying vector.
impl<T: Default, ID: Identifier> IdVec<ID, T>[src]
impl<T: Default, ID: Identifier> IdVec<ID, T>pub fn resize(&mut self, size: ID::Handle)[src]
pub fn resize(&mut self, size: ID::Handle)pub fn with_len(n: ID::Handle) -> Self[src]
pub fn with_len(n: ID::Handle) -> SelfCreates an IdVec with an n elements initialized to Default::default.
Trait Implementations
impl<ID: Identifier, T> Index<ID> for IdVec<ID, T>[src]
impl<ID: Identifier, T> Index<ID> for IdVec<ID, T>type Output = T
The returned type after indexing.
fn index<'l>(&'l self, id: ID) -> &'l T[src]
fn index<'l>(&'l self, id: ID) -> &'l TPerforms the indexing (container[index]) operation.
impl<ID: Identifier, T> IndexMut<ID> for IdVec<ID, T>[src]
impl<ID: Identifier, T> IndexMut<ID> for IdVec<ID, T>fn index_mut<'l>(&'l mut self, id: ID) -> &'l mut T[src]
fn index_mut<'l>(&'l mut self, id: ID) -> &'l mut TPerforms the mutable indexing (container[index]) operation.
impl<ID: Identifier, T> IntoIterator for IdVec<ID, T>[src]
impl<ID: Identifier, T> IntoIterator for IdVec<ID, T>type Item = 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) -> IntoIter<T>[src]
fn into_iter(self) -> IntoIter<T>Creates an iterator from a value. Read more
impl<'l, ID: Identifier, T> IntoIterator for &'l IdVec<ID, T>[src]
impl<'l, ID: Identifier, T> IntoIterator for &'l IdVec<ID, T>type Item = &'l T
The type of the elements being iterated over.
type IntoIter = Iter<'l, T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Iter<'l, T>[src]
fn into_iter(self) -> Iter<'l, T>Creates an iterator from a value. Read more
impl<'l, ID: Identifier, T> IntoIterator for &'l mut IdVec<ID, T>[src]
impl<'l, ID: Identifier, T> IntoIterator for &'l mut IdVec<ID, T>