pub struct EntityMap<E: Entity, V> { /* private fields */ }Expand description
A Vec-backed map keyed by EntityId<E>.
Implementations§
Source§impl<E: Entity, V> EntityMap<E, V>
impl<E: Entity, V> EntityMap<E, V>
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates an empty EntityMap with space for at least capacity values.
Sourcepub fn into_entity_vec(self) -> EntityVec<E, Option<V>>
pub fn into_entity_vec(self) -> EntityVec<E, Option<V>>
Cheap conversion to an EntityVec<E, Option<V>>
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 the highest occupied entity ID.
Sourcepub fn contains_key(&self, entity_id: EntityId<E>) -> bool
pub fn contains_key(&self, entity_id: EntityId<E>) -> bool
Returns true if entity_id is present in the map.
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 not present.
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 value for entity_id mutably, or None if not present.
Sourcepub fn insert(&mut self, entity_id: EntityId<E>, value: V) -> Option<V>
pub fn insert(&mut self, entity_id: EntityId<E>, value: V) -> Option<V>
Inserts value for entity_id, returning the previous value if one existed.
Sourcepub fn get_or_insert(&mut self, entity_id: EntityId<E>, value: V) -> &mut V
pub fn get_or_insert(&mut self, entity_id: EntityId<E>, value: V) -> &mut V
Returns the value for entity_id, inserting value if it is not already present.
Sourcepub fn get_or_insert_with<F>(&mut self, entity_id: EntityId<E>, f: F) -> &mut Vwhere
F: FnOnce() -> V,
pub fn get_or_insert_with<F>(&mut self, entity_id: EntityId<E>, f: F) -> &mut Vwhere
F: FnOnce() -> V,
Returns the value for entity_id, inserting a value from f if it is not already present.
Trait Implementations§
Source§impl<E: Entity, V> Extend<(EntityId<E>, V)> for EntityMap<E, V>
impl<E: Entity, V> Extend<(EntityId<E>, V)> for EntityMap<E, V>
Source§fn extend<I: IntoIterator<Item = (EntityId<E>, V)>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = (EntityId<E>, 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<'a, E: Entity, V> IntoIterator for &'a EntityMap<E, V>
impl<'a, E: Entity, V> IntoIterator for &'a EntityMap<E, V>
impl<E: Eq + Entity, V: Eq> Eq for EntityMap<E, V>
impl<E: Entity, V> StructuralPartialEq for EntityMap<E, V>
Auto Trait Implementations§
impl<E, V> Freeze for EntityMap<E, V>
impl<E, V> RefUnwindSafe for EntityMap<E, V>where
E: RefUnwindSafe,
V: RefUnwindSafe,
impl<E, V> Send for EntityMap<E, V>
impl<E, V> Sync for EntityMap<E, V>
impl<E, V> Unpin for EntityMap<E, V>
impl<E, V> UnwindSafe for EntityMap<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.