pub struct EntityPartVec<I: EntityId, V> { /* private fields */ }Expand description
A partial map backed by a vector.
An EntityPartVec stores at most one value V for each index I. Conceptually, this is
similar to e.g. a BTreeMap<I, V>.
Under the hood, this is backed by a Vec<Option<V>>. Thus, ideally the type V should have a
niche in its layout.
Implementations§
Source§impl<I: EntityId, V> EntityPartVec<I, V>
impl<I: EntityId, V> EntityPartVec<I, V>
pub fn new() -> Self
pub fn with_capacity(cap: usize) -> Self
pub fn is_empty(&self) -> bool
pub fn get(&self, id: I) -> Option<&V>
pub fn get_mut(&mut self, id: I) -> Option<&mut V>
pub fn contains_id(&self, id: I) -> bool
pub fn clear(&mut self)
Sourcepub fn insert(&mut self, id: I, val: V) -> Option<V>
pub fn insert(&mut self, id: I, val: V) -> Option<V>
Inserts the value val at position id, returning the previous value, if any.
pub fn into_ids(self) -> IntoIds<I, V> ⓘ
Sourcepub fn iter(&self) -> Iter<'_, I, V> ⓘ
pub fn iter(&self) -> Iter<'_, I, V> ⓘ
Returns an iterator of (id, &value) pairs.
IDs not present are skipped entirely.
Sourcepub fn iter_mut(&mut self) -> IterMut<'_, I, V> ⓘ
pub fn iter_mut(&mut self) -> IterMut<'_, I, V> ⓘ
Returns an iterator of (id, &mut value) pairs.
IDs not present are skipped entirely.
pub fn values(&self) -> Values<'_, I, V> ⓘ
pub fn values_mut(&mut self) -> ValuesMut<'_, I, V> ⓘ
pub fn into_values(self) -> IntoValues<I, V> ⓘ
Sourcepub fn try_into_full(self) -> Result<EntityVec<I, V>, I>
pub fn try_into_full(self) -> Result<EntityVec<I, V>, I>
pub fn map<O>(&self, f: impl FnMut(I, &V) -> O) -> EntityPartVec<I, O>
pub fn map_values<O>(&self, f: impl FnMut(&V) -> O) -> EntityPartVec<I, O>
Trait Implementations§
Source§impl<I, V> Debug for EntityPartVec<I, V>
impl<I, V> Debug for EntityPartVec<I, V>
Source§impl<I: EntityId, V> Default for EntityPartVec<I, V>
impl<I: EntityId, V> Default for EntityPartVec<I, V>
impl<I: Eq + EntityId, V: Eq> Eq for EntityPartVec<I, V>
Source§impl<I: EntityId, V> Extend<(I, V)> for EntityPartVec<I, V>
impl<I: EntityId, V> Extend<(I, V)> for EntityPartVec<I, V>
Source§fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = (I, V)>,
fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = (I, V)>,
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<(I, V)> for EntityPartVec<I, V>
impl<I: EntityId, V> FromIterator<(I, V)> for EntityPartVec<I, V>
Source§impl<I: EntityId, V> Index<I> for EntityPartVec<I, V>
impl<I: EntityId, V> Index<I> for EntityPartVec<I, V>
Source§impl<I: EntityId, V> IndexMut<I> for EntityPartVec<I, V>
impl<I: EntityId, V> IndexMut<I> for EntityPartVec<I, V>
Source§impl<I: EntityId, V> IntoIterator for EntityPartVec<I, V>
impl<I: EntityId, V> IntoIterator for EntityPartVec<I, V>
Source§impl<'a, I: EntityId, V> IntoIterator for &'a EntityPartVec<I, V>
impl<'a, I: EntityId, V> IntoIterator for &'a EntityPartVec<I, V>
Source§impl<'a, I: EntityId, V> IntoIterator for &'a mut EntityPartVec<I, V>
impl<'a, I: EntityId, V> IntoIterator for &'a mut EntityPartVec<I, V>
impl<I: PartialEq + EntityId, V: PartialEq> StructuralPartialEq for EntityPartVec<I, V>
Auto Trait Implementations§
impl<I, V> Freeze for EntityPartVec<I, V>
impl<I, V> RefUnwindSafe for EntityPartVec<I, V>where
I: RefUnwindSafe,
V: RefUnwindSafe,
impl<I, V> Send for EntityPartVec<I, V>where
V: Send,
impl<I, V> Sync for EntityPartVec<I, V>where
V: Sync,
impl<I, V> Unpin for EntityPartVec<I, V>
impl<I, V> UnsafeUnpin for EntityPartVec<I, V>
impl<I, V> UnwindSafe for EntityPartVec<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> 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.