pub struct IndexVec<I, T>where
I: Idx,{ /* private fields */ }Expand description
A dense vector indexed by ID types.
This provides O(1) access and storage for dense ID-indexed data.
Implementations§
Source§impl<I, T> IndexVec<I, T>where
I: Idx,
impl<I, T> IndexVec<I, T>where
I: Idx,
Sourcepub fn with_capacity(n: usize) -> IndexVec<I, T>
pub fn with_capacity(n: usize) -> IndexVec<I, T>
Create a new IndexVec with pre-allocated capacity.
Sourcepub fn push(&mut self, v: T) -> Result<I, IndexedVecError>
pub fn push(&mut self, v: T) -> Result<I, IndexedVecError>
Push an element and return its ID.
Returns an error if the length would exceed the maximum representable by the ID type.
Sourcepub fn get(&self, idx: I) -> Option<&T>
pub fn get(&self, idx: I) -> Option<&T>
Get an element by ID, returning None if the ID is out of bounds.
Sourcepub fn into_inner(self) -> Vec<T>
pub fn into_inner(self) -> Vec<T>
Consume this IndexVec and return the underlying Vec.
Sourcepub fn swap_remove(&mut self, index: usize) -> T
pub fn swap_remove(&mut self, index: usize) -> T
Remove an element at the specified index and return it.
Trait Implementations§
Source§impl<'a, I, T> IntoIterator for &'a IndexVec<I, T>where
I: Idx,
impl<'a, I, T> IntoIterator for &'a IndexVec<I, T>where
I: Idx,
Source§impl<I, T> IntoIterator for IndexVec<I, T>where
I: Idx,
impl<I, T> IntoIterator for IndexVec<I, T>where
I: Idx,
Source§impl<I, T> LookupByIdx<I, T> for IndexVec<I, T>where
I: Idx,
impl<I, T> LookupByIdx<I, T> for IndexVec<I, T>where
I: Idx,
impl<I, T> Eq for IndexVec<I, T>
impl<I, T> StructuralPartialEq for IndexVec<I, T>where
I: Idx,
Auto Trait Implementations§
impl<I, T> Freeze for IndexVec<I, T>
impl<I, T> RefUnwindSafe for IndexVec<I, T>where
I: RefUnwindSafe,
T: RefUnwindSafe,
impl<I, T> Send for IndexVec<I, T>
impl<I, T> Sync for IndexVec<I, T>
impl<I, T> Unpin for IndexVec<I, T>
impl<I, T> UnwindSafe for IndexVec<I, T>where
I: UnwindSafe,
T: UnwindSafe,
Blanket Implementations§
Source§impl<'a, F, I> BatchInvert<F> for I
impl<'a, F, I> BatchInvert<F> for I
Source§fn batch_invert(self) -> F
fn batch_invert(self) -> F
Consumes this iterator and inverts each field element (when nonzero). Zero-valued
elements are left as zero. Read more
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more