Struct IndexVec

Source
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>

Source

pub fn new() -> Self

Source

pub fn from_raw(raw: Vec<T>) -> Self

Source

pub fn with_capacity(capacity: usize) -> Self

Source

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

Source

pub fn push(&mut self, d: T) -> I

Source

pub fn pop(&mut self) -> Option<T>

Source

pub fn len(&self) -> usize

Source

pub fn next_index(&self) -> I

Gives the next index that will be assigned when push is called.

Source

pub fn is_empty(&self) -> bool

Source

pub fn into_iter(self) -> IntoIter<T>

Source

pub fn into_iter_enumerated(self) -> Enumerated<I, IntoIter<T>>

Source

pub fn iter(&self) -> Iter<'_, T>

Source

pub fn iter_enumerated(&self) -> Enumerated<I, Iter<'_, T>>

Source

pub fn indices(&self) -> Map<Range<usize>, IntoIdx<I>>

Source

pub fn iter_mut(&mut self) -> IterMut<'_, T>

Source

pub fn iter_enumerated_mut(&mut self) -> Enumerated<I, IterMut<'_, T>>

Source

pub fn drain<'a, R: RangeBounds<usize>>( &'a mut self, range: R, ) -> impl Iterator<Item = T> + 'a

Source

pub fn drain_enumerated<'a, R: RangeBounds<usize>>( &'a mut self, range: R, ) -> impl Iterator<Item = (I, T)> + 'a

Source

pub fn last(&self) -> Option<I>

Source

pub fn shrink_to_fit(&mut self)

Source

pub fn swap(&mut self, a: I, b: I)

Source

pub fn truncate(&mut self, a: usize)

Source

pub fn get(&self, index: I) -> Option<&T>

Source

pub fn get_mut(&mut self, index: I) -> Option<&mut T>

Source

pub fn convert_index_type<Ix: Idx>(self) -> IndexVec<Ix, T>

Source

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.

Source

pub fn resize_to_elem(&mut self, elem: I, fill_value: impl FnMut() -> T)

Trait Implementations§

Source§

impl<I: Clone + Idx, T: Clone> Clone for IndexVec<I, T>

Source§

fn clone(&self) -> IndexVec<I, T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<I: Debug + Idx, T: Debug> Debug for IndexVec<I, T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<I: Idx, T> Default for IndexVec<I, T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<I: Hash + Idx, T: Hash> Hash for IndexVec<I, T>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<I: Idx, T> Index<I> for IndexVec<I, T>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: I) -> &T

Performs the indexing (container[index]) operation. Read more
Source§

impl<I: Idx, T> IndexMut<I> for IndexVec<I, T>

Source§

fn index_mut(&mut self, index: I) -> &mut T

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<I: PartialEq + Idx, T: PartialEq> PartialEq for IndexVec<I, T>

Source§

fn eq(&self, other: &IndexVec<I, T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<I: Eq + Idx, T: Eq> Eq for IndexVec<I, T>

Source§

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>

§

impl<I, T> Send for IndexVec<I, T>
where I: Send, T: Send,

§

impl<I, T> Sync for IndexVec<I, T>
where I: Sync, T: Sync,

§

impl<I, T> Unpin for IndexVec<I, T>
where I: Unpin, T: Unpin,

§

impl<I, T> UnwindSafe for IndexVec<I, T>
where I: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.