Struct rustc_index::vec::IndexVec
source · pub struct IndexVec<I: Idx, T> {
pub raw: Vec<T>,
_marker: PhantomData<fn(_: &I)>,
}
Fields
raw: Vec<T>
_marker: PhantomData<fn(_: &I)>
Implementations
sourceimpl<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
pub fn from_elem<S>(elem: T, universe: &IndexVec<I, S>) -> Selfwhere
T: Clone,
pub fn from_elem_n(elem: T, n: usize) -> Selfwhere
T: Clone,
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
) -> impl DoubleEndedIterator<Item = (I, T)> + ExactSizeIterator
pub fn iter(&self) -> Iter<'_, T>
pub fn iter_enumerated(
&self
) -> impl DoubleEndedIterator<Item = (I, &T)> + ExactSizeIterator + '_
pub fn indices(
&self
) -> impl DoubleEndedIterator<Item = I> + ExactSizeIterator + Clone + 'static
pub fn iter_mut(&mut self) -> IterMut<'_, T>
pub fn iter_enumerated_mut(
&mut self
) -> impl DoubleEndedIterator<Item = (I, &mut T)> + ExactSizeIterator + '_
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>
sourcepub fn pick2_mut(&mut self, a: I, b: I) -> (&mut T, &mut T)
pub fn pick2_mut(&mut self, a: I, b: I) -> (&mut T, &mut T)
Returns mutable references to two distinct elements, a
and b
.
Panics if a == b
.
sourcepub fn pick3_mut(&mut self, a: I, b: I, c: I) -> (&mut T, &mut T, &mut T)
pub fn pick3_mut(&mut self, a: I, b: I, c: I) -> (&mut T, &mut T, &mut T)
Returns mutable references to three distinct elements.
Panics if the elements are not distinct.
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
sourceimpl<I: Idx, T> Extend<T> for IndexVec<I, T>
impl<I: Idx, T> Extend<T> for IndexVec<I, T>
sourcefn extend<J: IntoIterator<Item = T>>(&mut self, iter: J)
fn extend<J: IntoIterator<Item = T>>(&mut self, iter: J)
sourcefn extend_one(&mut self, item: T)
fn extend_one(&mut self, item: T)
extend_one
)sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)sourceimpl<I: Idx, T> FromIterator<T> for IndexVec<I, T>
impl<I: Idx, T> FromIterator<T> for IndexVec<I, T>
sourcefn from_iter<J>(iter: J) -> Selfwhere
J: IntoIterator<Item = T>,
fn from_iter<J>(iter: J) -> Selfwhere
J: IntoIterator<Item = T>,
sourceimpl<'a, I: Idx, T> IntoIterator for &'a IndexVec<I, T>
impl<'a, I: Idx, T> IntoIterator for &'a IndexVec<I, T>
sourceimpl<'a, I: Idx, T> IntoIterator for &'a mut IndexVec<I, T>
impl<'a, I: Idx, T> IntoIterator for &'a mut IndexVec<I, T>
sourceimpl<I: Idx, T> IntoIterator for IndexVec<I, T>
impl<I: Idx, T> IntoIterator for IndexVec<I, T>
sourceimpl<I: PartialEq + Idx, T: PartialEq> PartialEq<IndexVec<I, T>> for IndexVec<I, T>
impl<I: PartialEq + Idx, T: PartialEq> PartialEq<IndexVec<I, T>> for IndexVec<I, T>
impl<I: Eq + Idx, T: Eq> Eq for IndexVec<I, T>
impl<I: Idx, T> Send for IndexVec<I, T>where
T: Send,
impl<I: Idx, T> StructuralEq for IndexVec<I, T>
impl<I: Idx, T> StructuralPartialEq for IndexVec<I, T>
Auto Trait Implementations
impl<I, T> RefUnwindSafe for IndexVec<I, T>where
T: RefUnwindSafe,
impl<I, T> Sync for IndexVec<I, T>where
T: Sync,
impl<I, T> Unpin for IndexVec<I, T>where
T: Unpin,
impl<I, T> UnwindSafe for IndexVec<I, T>where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Layout
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.
Size: 24 bytes