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]
fn new() -> Self[src]
Create an empty IdVec
fn with_capacity(size: ID::Handle) -> Self[src]
Create an IdVec with preallocated storage
fn from_vec(vec: Vec<T>) -> Self[src]
Create an IdVec by recycling a Vec and its content.
fn into_vec(self) -> Vec<T>[src]
Consume the IdVec and create a Vec.
fn as_vec(&self) -> &Vec<T>[src]
Exposes the internal Vec.
fn len(&self) -> ID::Handle[src]
Number of elements in the IdVec
fn is_empty(&self) -> bool[src]
Returns true if the vector contains no elements.
fn as_slice(&self) -> IdSlice<ID, T>[src]
Extracts a slice containing the entire vector.
fn as_mut_slice(&mut self) -> MutIdSlice<ID, T>[src]
Extracts a mutable slice containing the entire vector.
fn range(&self, ids: IdRange<ID::Tag, ID::Handle>) -> IdSlice<ID, T>[src]
fn mut_range(&mut self, ids: IdRange<ID::Tag, ID::Handle>) -> MutIdSlice<ID, T>[src]
fn range_from(&self, id: ID) -> IdSlice<ID, T>[src]
fn mut_range_from(&mut self, id: ID) -> MutIdSlice<ID, T>[src]
fn range_to(&self, id: ID) -> IdSlice<ID, T>[src]
fn mut_range_to(&mut self, id: ID) -> MutIdSlice<ID, T>[src]
fn nth(&self, idx: ID::Handle) -> &T[src]
Return the nth element of the IdVec using an usize index rather than an Id (à la Vec).
fn nth_mut(&mut self, idx: ID::Handle) -> &mut T[src]
Return the nth element of the IdVec using an usize index rather than an Id (à la Vec).
fn iter<'l>(&'l self) -> Iter<'l, T>[src]
Iterate over the elements of the IdVec
fn iter_mut<'l>(&'l mut self) -> IterMut<'l, T>[src]
Iterate over the elements of the IdVec
fn push(&mut self, elt: T) -> ID[src]
Add an element to the IdVec and return its Id. This method can cause the storage to be reallocated.
fn reserve(&mut self, additional: ID::Handle)[src]
Reserves capacity for at least additional more elements to be inserted in the given vector.
fn shrink_to_fit(&mut self)[src]
Shrinks the capacity of the vector as much as possible.
fn clear(&mut self)[src]
Drop all of the contained elements and clear the IdVec's storage.
fn remove(&mut self, index: ID) -> T[src]
Removes and returns the element at position index within the vector, shifting all elements after it to the left.
fn swap_remove(&mut self, index: ID) -> T[src]
Removes an element from the vector and returns it. The removed element is replaced by the last element of the vector.
fn has_id(&self, id: ID) -> bool[src]
fn first_id(&self) -> Option<ID>[src]
impl<ID: Identifier, T: Default> IdVec<ID, T>[src]
fn set(&mut self, id: ID, val: T)[src]
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]
fn resize(&mut self, size: ID::Handle)[src]
fn with_len(n: ID::Handle) -> Self[src]
Creates an IdVec with an n elements initialized to Default::default.
Trait Implementations
impl<ID: Identifier, T> Index<ID> for IdVec<ID, T>[src]
type Output = T
The returned type after indexing.
fn index<'l>(&'l self, id: ID) -> &'l T[src]
Performs the indexing (container[index]) operation.