[][src]Struct sid::IdVec

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]

pub fn new() -> Self[src]

Create an empty IdVec

pub fn with_capacity(size: ID::Handle) -> Self[src]

Create an IdVec with preallocated storage

pub fn from_vec(vec: Vec<T>) -> Self[src]

Create an IdVec by recycling a Vec and its content.

pub fn into_vec(self) -> Vec<T>[src]

Consume the IdVec and create a Vec.

pub fn as_vec(&self) -> &Vec<T>[src]

Exposes the internal Vec.

pub fn len(&self) -> ID::Handle[src]

Number of elements in the IdVec

pub fn is_empty(&self) -> bool[src]

Returns true if the vector contains no elements.

pub fn as_slice(&self) -> IdSlice<ID, T>[src]

Extracts a slice containing the entire vector.

pub fn as_mut_slice(&mut self) -> MutIdSlice<ID, T>[src]

Extracts a mutable slice containing the entire vector.

pub fn range(&self, ids: IdRange<ID::Tag, ID::Handle>) -> IdSlice<ID, T>[src]

pub fn mut_range(
    &mut self,
    ids: IdRange<ID::Tag, ID::Handle>
) -> MutIdSlice<ID, T>
[src]

pub fn range_from(&self, id: ID) -> IdSlice<ID, T>[src]

pub fn mut_range_from(&mut self, id: ID) -> MutIdSlice<ID, T>[src]

pub fn range_to(&self, id: ID) -> IdSlice<ID, T>[src]

pub fn mut_range_to(&mut self, id: ID) -> MutIdSlice<ID, T>[src]

pub fn range_to_inclusive(&self, id: ID) -> IdSlice<ID, T>[src]

pub fn mut_range_to_inclusive(&mut self, id: ID) -> MutIdSlice<ID, T>[src]

pub 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).

pub 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).

pub fn iter<'l>(&'l self) -> Iter<'l, T>[src]

Iterate over the elements of the IdVec

pub fn iter_mut<'l>(&'l mut self) -> IterMut<'l, T>[src]

Iterate over the elements of the IdVec

pub 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.

pub fn insert(&mut self, id: ID, elt: T)[src]

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]

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]

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]

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]

Clones and appends all elements in a slice to the vector.

pub fn reserve(&mut self, additional: ID::Handle)[src]

Reserves capacity for at least additional more elements to be inserted in the given vector.

pub fn shrink_to_fit(&mut self)[src]

Shrinks the capacity of the vector as much as possible.

pub fn clear(&mut self)[src]

Drop all of the contained elements and clear the IdVec's storage.

pub 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.

pub 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.

pub fn has_id(&self, id: ID) -> bool[src]

pub fn first_id(&self) -> Option<ID>[src]

pub fn last_id(&self) -> Option<ID>[src]

Important traits for IdRange<T, H>
pub fn ids(&self) -> IdRange<ID::Tag, ID::Handle>[src]

impl<ID: Identifier, T: Default> IdVec<ID, T>[src]

pub 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]

pub fn resize(&mut self, size: ID::Handle)[src]

pub 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.

impl<ID: Identifier, T> IndexMut<ID> for IdVec<ID, T>[src]

impl<ID: Identifier, T> IntoIterator for IdVec<ID, T>[src]

type Item = T

The type of the elements being iterated over.

type IntoIter = IntoIter<T>

Which kind of iterator are we turning this into?

impl<'l, ID: Identifier, T> IntoIterator for &'l IdVec<ID, T>[src]

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?

impl<'l, ID: Identifier, T> IntoIterator for &'l mut IdVec<ID, T>[src]

type Item = &'l mut T

The type of the elements being iterated over.

type IntoIter = IterMut<'l, T>

Which kind of iterator are we turning this into?

impl<ID: Identifier, T: Clone> Clone for IdVec<ID, T>[src]

Auto Trait Implementations

impl<ID, T> Unpin for IdVec<ID, T> where
    ID: Unpin,
    T: Unpin

impl<ID, T> Send for IdVec<ID, T> where
    ID: Send,
    T: Send

impl<ID, T> Sync for IdVec<ID, T> where
    ID: Sync,
    T: Sync

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.