Struct sid_vec::IdVec
[−]
[src]
pub struct IdVec<ID: Identifier, Data> { /* 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, Data> IdVec<ID, Data>
[src]
fn new() -> IdVec<ID, Data>
Create an empty IdVec
fn with_capacity(size: ID::Handle) -> IdVec<ID, Data>
Create an IdVec with preallocated storage
fn from_vec(vec: Vec<Data>) -> IdVec<ID, Data>
Create an IdVec by recycling a Vec and its content.
fn into_vec(self) -> Vec<Data>
Consume the IdVec and create a Vec.
fn len(&self) -> usize
Number of elements in the IdVec
fn nth(&self, idx: usize) -> &Data
Return the nth element of the IdVec using an usize index rather than an Id (à la Vec).
fn nth_mut(&mut self, idx: usize) -> &mut Data
Return the nth element of the IdVec using an usize index rather than an Id (à la Vec).
fn iter<'l>(&'l self) -> Iter<'l, Data>
Iterate over the elements of the IdVec
fn iter_mut<'l>(&'l mut self) -> IterMut<'l, Data>
Iterate over the elements of the IdVec
fn push(&mut self, elt: Data) -> ID
Add an element to the IdVec and return its Id. This method can cause the storage to be reallocated.
fn clear(&mut self)
Drop all of the contained elements and clear the IdVec's storage.
impl<ID: Identifier, Data: Default> IdVec<ID, Data>
[src]
fn set(&mut self, id: ID, val: Data)
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<Data: Default, ID: Identifier> IdVec<ID, Data>
[src]
fn resize(&mut self, size: ID::Handle)
fn with_len(n: ID::Handle) -> Self
Creates an IdVec with an n elements initialized to Default::default
.
Trait Implementations
impl<ID: Identifier, Data> Index<ID> for IdVec<ID, Data>
[src]
type Output = Data
The returned type after indexing
fn index<'l>(&'l self, id: ID) -> &'l Data
The method for the indexing (container[index]
) operation
impl<ID: Identifier, Data> IndexMut<ID> for IdVec<ID, Data>
[src]
fn index_mut<'l>(&'l mut self, id: ID) -> &'l mut Data
The method for the mutable indexing (container[index]
) operation