pub struct EntityBundleMap<I: EntityId, T> { /* private fields */ }Expand description
A map where each key-value pair is assigned a contiguous range of IDs.
An EntityBundleMap is a collection of bundles. Each bundle consists of a key, a value,
and a range of IDs assigned to it. The amount of IDs assigned to a bundle is determined by
its shape: an array of a specified size, or just a single unit.
Note that we distinguish between a single unit and an array of size one. This is
intentional, as this datastructure is used to implement data models that make this distinction,
much like Rust makes a distinction between u32 and [u32; 1].
Implementations§
Source§impl<I: EntityId, T> EntityBundleMap<I, T>
impl<I: EntityId, T> EntityBundleMap<I, T>
pub fn new() -> Self
pub fn is_empty(&self) -> bool
pub fn ids(&self) -> impl DoubleEndedIterator<Item = I> + '_
Sourcepub fn get(&self, key: &str) -> Option<(EntityBundleIndices<I>, &T)>
pub fn get(&self, key: &str) -> Option<(EntityBundleIndices<I>, &T)>
Retrieve a bundle by its key.
pub fn get_mut(&mut self, key: &str) -> Option<(EntityBundleIndices<I>, &mut T)>
pub fn contains_key(&self, key: &str) -> bool
Sourcepub fn key(&self, id: I) -> (&str, EntityBundleItemIndex)
pub fn key(&self, id: I) -> (&str, EntityBundleItemIndex)
Given an ID, returns the key of the bundle which owns that ID, as well as the particular position within the bundle that corresponds to the ID.
Sourcepub fn insert(
&mut self,
ids: impl Into<EntityBundleIndices<I>>,
name: String,
value: T,
) -> Result<(), DuplicateKeyError>
pub fn insert( &mut self, ids: impl Into<EntityBundleIndices<I>>, name: String, value: T, ) -> Result<(), DuplicateKeyError>
Insert a bundle.
pub fn iter(&self) -> impl Iterator<Item = (I, &str, EntityBundleItemIndex, &T)>
pub fn bundles( &self, ) -> impl Iterator<Item = (EntityBundleIndices<I>, &str, &T)>
pub fn bundles_mut( &mut self, ) -> impl Iterator<Item = (EntityBundleIndices<I>, &str, &mut T)>
pub fn into_bundles( self, ) -> impl Iterator<Item = (EntityBundleIndices<I>, String, T)>
Trait Implementations§
Source§impl<I: EntityId, T> Default for EntityBundleMap<I, T>
impl<I: EntityId, T> Default for EntityBundleMap<I, T>
impl<I: Eq + EntityId, T: Eq> Eq for EntityBundleMap<I, T>
Source§impl<I: EntityId, T> Index<I> for EntityBundleMap<I, T>
impl<I: EntityId, T> Index<I> for EntityBundleMap<I, T>
Source§impl<I: EntityId, T> IndexMut<I> for EntityBundleMap<I, T>
impl<I: EntityId, T> IndexMut<I> for EntityBundleMap<I, T>
impl<I: PartialEq + EntityId, T: PartialEq> StructuralPartialEq for EntityBundleMap<I, T>
Auto Trait Implementations§
impl<I, T> Freeze for EntityBundleMap<I, T>
impl<I, T> RefUnwindSafe for EntityBundleMap<I, T>where
I: RefUnwindSafe,
T: RefUnwindSafe,
impl<I, T> Send for EntityBundleMap<I, T>where
T: Send,
impl<I, T> Sync for EntityBundleMap<I, T>where
T: Sync,
impl<I, T> Unpin for EntityBundleMap<I, T>
impl<I, T> UnsafeUnpin for EntityBundleMap<I, T>
impl<I, T> UnwindSafe for EntityBundleMap<I, T>where
I: UnwindSafe,
T: 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.