pub struct EntityVec<E: Entity, V> { /* private fields */ }Expand description
A Vec-backed collection indexed by EntityId<E>.
Implementations§
Source§impl<E: Entity, V> EntityVec<E, V>
impl<E: Entity, V> EntityVec<E, V>
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates an empty EntityVec with space for at least capacity items.
Sourcepub fn reserve(&mut self, additional: usize)
pub fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional more values.
Sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Shrinks the backing vector to fit its length.
Sourcepub fn get(&self, entity_id: EntityId<E>) -> Option<&V>
pub fn get(&self, entity_id: EntityId<E>) -> Option<&V>
Returns the value for entity_id, or None if this vector is not long enough.
Sourcepub fn get_mut(&mut self, entity_id: EntityId<E>) -> Option<&mut V>
pub fn get_mut(&mut self, entity_id: EntityId<E>) -> Option<&mut V>
Returns the mutable value for entity_id, or None if this vector is not long enough.
Sourcepub fn as_mut_slice(&mut self) -> &mut [V]
pub fn as_mut_slice(&mut self) -> &mut [V]
Returns the backing slice mutably.
Sourcepub fn iter_mut(&mut self) -> IterMut<'_, V>
pub fn iter_mut(&mut self) -> IterMut<'_, V>
Returns a mutable iterator over the stored values.
Sourcepub fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = V>,
pub fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = V>,
Extends the vector with values from iter, assigning contiguous IDs to new items.
Sourcepub fn resize(&mut self, new_len: usize, value: V)where
V: Clone,
pub fn resize(&mut self, new_len: usize, value: V)where
V: Clone,
Resizes the vector to new_len, cloning value as needed.
Sourcepub fn resize_with<F>(&mut self, new_len: usize, f: F)where
F: FnMut() -> V,
pub fn resize_with<F>(&mut self, new_len: usize, f: F)where
F: FnMut() -> V,
Resizes the vector to new_len, generating values with f as needed.
Trait Implementations§
Source§impl<E: Entity, V> Extend<V> for EntityVec<E, V>
impl<E: Entity, V> Extend<V> for EntityVec<E, V>
Source§fn extend<I: IntoIterator<Item = V>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = V>>(&mut self, iter: I)
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬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<E: Entity, V> FromIterator<V> for EntityVec<E, V>
impl<E: Entity, V> FromIterator<V> for EntityVec<E, V>
Source§fn from_iter<I: IntoIterator<Item = V>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = V>>(iter: I) -> Self
Creates a value from an iterator. Read more
Source§impl<'a, E: Entity, V> IntoIterator for &'a EntityVec<E, V>
impl<'a, E: Entity, V> IntoIterator for &'a EntityVec<E, V>
Source§impl<'a, E: Entity, V> IntoIterator for &'a mut EntityVec<E, V>
impl<'a, E: Entity, V> IntoIterator for &'a mut EntityVec<E, V>
Source§impl<E: Entity, V> IntoIterator for EntityVec<E, V>
impl<E: Entity, V> IntoIterator for EntityVec<E, V>
impl<E: Eq + Entity, V: Eq> Eq for EntityVec<E, V>
impl<E: Entity, V> StructuralPartialEq for EntityVec<E, V>
Auto Trait Implementations§
impl<E, V> Freeze for EntityVec<E, V>
impl<E, V> RefUnwindSafe for EntityVec<E, V>where
E: RefUnwindSafe,
V: RefUnwindSafe,
impl<E, V> Send for EntityVec<E, V>
impl<E, V> Sync for EntityVec<E, V>
impl<E, V> Unpin for EntityVec<E, V>
impl<E, V> UnwindSafe for EntityVec<E, V>where
E: UnwindSafe,
V: UnwindSafe,
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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.§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Returns the layout of the type.