pub struct IndexVec<I: Idx, T> {
pub raw: Vec<T>,
/* private fields */
}
Fields§
§raw: Vec<T>
Implementations§
Source§impl<I: Idx, T> IndexVec<I, T>
impl<I: Idx, T> IndexVec<I, T>
pub fn new() -> Self
pub fn from_raw(raw: Vec<T>) -> Self
pub fn with_capacity(capacity: usize) -> Self
Sourcepub fn from_fn_n(func: impl FnMut(I) -> T, n: usize) -> Self
pub fn from_fn_n(func: impl FnMut(I) -> T, n: usize) -> Self
Create an IndexVec
with n
elements, where the value of each
element is the result of func(i)
. (The underlying vector will
be allocated only once, with a capacity of at least n
.)
pub fn push(&mut self, d: T) -> I
pub fn pop(&mut self) -> Option<T>
pub fn len(&self) -> usize
Sourcepub fn next_index(&self) -> I
pub fn next_index(&self) -> I
Gives the next index that will be assigned when push
is
called.
pub fn is_empty(&self) -> bool
pub fn into_iter(self) -> IntoIter<T>
pub fn into_iter_enumerated(self) -> Enumerated<I, IntoIter<T>>
pub fn iter(&self) -> Iter<'_, T>
pub fn iter_enumerated(&self) -> Enumerated<I, Iter<'_, T>>
pub fn indices(&self) -> Map<Range<usize>, IntoIdx<I>> ⓘ
pub fn iter_mut(&mut self) -> IterMut<'_, T>
pub fn iter_enumerated_mut(&mut self) -> Enumerated<I, IterMut<'_, T>>
pub fn drain<'a, R: RangeBounds<usize>>( &'a mut self, range: R, ) -> impl Iterator<Item = T> + 'a
pub fn drain_enumerated<'a, R: RangeBounds<usize>>( &'a mut self, range: R, ) -> impl Iterator<Item = (I, T)> + 'a
pub fn last(&self) -> Option<I>
pub fn shrink_to_fit(&mut self)
pub fn swap(&mut self, a: I, b: I)
pub fn truncate(&mut self, a: usize)
pub fn get(&self, index: I) -> Option<&T>
pub fn get_mut(&mut self, index: I) -> Option<&mut T>
pub fn convert_index_type<Ix: Idx>(self) -> IndexVec<Ix, T>
Sourcepub fn ensure_contains_elem(&mut self, elem: I, fill_value: impl FnMut() -> T)
pub fn ensure_contains_elem(&mut self, elem: I, fill_value: impl FnMut() -> T)
Grows the index vector so that it contains an entry for
elem
; if that is already true, then has no
effect. Otherwise, inserts new values as needed by invoking
fill_value
.
pub fn resize_to_elem(&mut self, elem: I, fill_value: impl FnMut() -> T)
Trait Implementations§
impl<I: Eq + Idx, T: Eq> Eq for IndexVec<I, T>
impl<I: Idx, T> StructuralPartialEq for IndexVec<I, T>
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<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