pub struct EntityVec<I: EntityId, V> { /* private fields */ }Expand description
A vector with strongly-typed indices.
Implementations§
Source§impl<I: EntityId, V> EntityVec<I, V>
impl<I: EntityId, V> EntityVec<I, V>
Sourcepub fn with_capacity(cap: usize) -> Self
pub fn with_capacity(cap: usize) -> Self
See Vec::with_capacity.
pub fn get(&self, idx: I) -> Option<&V>
pub fn get_mut(&mut self, idx: I) -> Option<&mut V>
Sourcepub unsafe fn get_unchecked(&self, idx: I) -> &V
pub unsafe fn get_unchecked(&self, idx: I) -> &V
Obtains a reference to a given element of the vector, without checking index validity.
§Safety
The caller must ensure that idx is a valid index within this vector.
Sourcepub unsafe fn get_unchecked_mut(&mut self, idx: I) -> &mut V
pub unsafe fn get_unchecked_mut(&mut self, idx: I) -> &mut V
Obtains a mutable reference to a given element of the vector, without checking index validity.
§Safety
The caller must ensure that idx is a valid index within this vector.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn clear(&mut self)
pub fn ids(&self) -> EntityRange<I>
pub fn values(&self) -> Iter<'_, V> ⓘ
pub fn values_mut(&mut self) -> IterMut<'_, V> ⓘ
pub fn into_values(self) -> IntoIter<V> ⓘ
pub fn iter(&self) -> Iter<'_, I, V> ⓘ
pub fn iter_mut(&mut self) -> IterMut<'_, I, V> ⓘ
pub fn map<'a, NV>(&'a self, f: impl FnMut(I, &'a V) -> NV) -> EntityVec<I, NV>
pub fn map_values<'a, NV>( &'a self, f: impl FnMut(&'a V) -> NV, ) -> EntityVec<I, NV>
pub fn into_map_values<NV>(self, f: impl FnMut(V) -> NV) -> EntityVec<I, NV>
pub fn first(&self) -> Option<&V>
pub fn first_mut(&mut self) -> Option<&mut V>
pub fn first_id(&self) -> Option<I>
pub fn last(&self) -> Option<&V>
pub fn last_mut(&mut self) -> Option<&mut V>
pub fn last_id(&self) -> Option<I>
pub fn next_id(&self) -> I
Sourcepub fn binary_search(&self, x: &V) -> Result<I, I>where
V: Ord,
pub fn binary_search(&self, x: &V) -> Result<I, I>where
V: Ord,
See [[T]::binary_search].
Sourcepub fn binary_search_by<'a, F>(&'a self, f: F) -> Result<I, I>
pub fn binary_search_by<'a, F>(&'a self, f: F) -> Result<I, I>
See [[T]::binary_search_by].
Sourcepub fn binary_search_by_key<'a, B, F>(&'a self, b: &B, f: F) -> Result<I, I>
pub fn binary_search_by_key<'a, B, F>(&'a self, b: &B, f: F) -> Result<I, I>
See [[T]::binary_search_by_key].
pub fn pop(&mut self) -> Option<(I, V)>
Trait Implementations§
impl<I: Eq + EntityId, V: Eq> Eq for EntityVec<I, V>
Source§impl<I: EntityId, V> Extend<V> for EntityVec<I, V>
impl<I: EntityId, V> Extend<V> for EntityVec<I, V>
Source§fn extend<T: IntoIterator<Item = V>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = V>>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: T)
fn extend_one(&mut self, item: T)
🔬This is a nightly-only experimental API. (
extend_one)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
Source§impl<I: EntityId, V> FromIterator<V> for EntityVec<I, V>
impl<I: EntityId, V> FromIterator<V> for EntityVec<I, V>
Source§fn from_iter<T>(iter: T) -> Selfwhere
T: IntoIterator<Item = V>,
fn from_iter<T>(iter: T) -> Selfwhere
T: IntoIterator<Item = V>,
Creates a value from an iterator. Read more
Source§impl<I: EntityId, V> IntoIterator for EntityVec<I, V>
impl<I: EntityId, V> IntoIterator for EntityVec<I, V>
Source§impl<'a, I: EntityId, V> IntoIterator for &'a EntityVec<I, V>
impl<'a, I: EntityId, V> IntoIterator for &'a EntityVec<I, V>
Source§impl<'a, I: EntityId, V> IntoIterator for &'a mut EntityVec<I, V>
impl<'a, I: EntityId, V> IntoIterator for &'a mut EntityVec<I, V>
Source§impl<I: Ord + EntityId, V: Ord> Ord for EntityVec<I, V>
impl<I: Ord + EntityId, V: Ord> Ord for EntityVec<I, V>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl<I: PartialOrd + EntityId, V: PartialOrd> PartialOrd for EntityVec<I, V>
impl<I: PartialOrd + EntityId, V: PartialOrd> PartialOrd for EntityVec<I, V>
impl<I: PartialEq + EntityId, V: PartialEq> StructuralPartialEq for EntityVec<I, V>
Auto Trait Implementations§
impl<I, V> Freeze for EntityVec<I, V>
impl<I, V> RefUnwindSafe for EntityVec<I, V>where
I: RefUnwindSafe,
V: RefUnwindSafe,
impl<I, V> Send for EntityVec<I, V>where
V: Send,
impl<I, V> Sync for EntityVec<I, V>where
V: Sync,
impl<I, V> Unpin for EntityVec<I, V>
impl<I, V> UnsafeUnpin for EntityVec<I, V>
impl<I, V> UnwindSafe for EntityVec<I, V>where
I: UnwindSafe,
V: 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.