Struct shipyard::SparseSet [−][src]
Default component storage.
Implementations
impl<T> SparseSet<T>[src]
impl<T> SparseSet<T>[src]
pub fn contains(&self, entity: EntityId) -> bool[src]
Returns true if entity owns a component in this storage.
pub fn len(&self) -> usize[src]
Returns the length of the storage.
pub fn is_empty(&self) -> bool[src]
Returns true if the storage’s length is 0.
impl<T> SparseSet<T>[src]
pub fn index_of(&self, entity: EntityId) -> Option<usize>[src]
Returns the index of entity’s component in the dense and data vectors.
This index is only valid for this storage and until a modification happens.
pub unsafe fn index_of_unchecked(&self, entity: EntityId) -> usize[src]
Returns the index of entity’s component in the dense and data vectors.
This index is only valid for this storage and until a modification happens.
Safety
entity has to own a component of this type.
The index is only valid until a modification occurs in the storage.
pub fn id_at(&self, index: usize) -> Option<EntityId>[src]
Returns the EntityId at a given index.
impl<T> SparseSet<T>[src]
pub fn remove(&mut self, entity: EntityId) -> Option<T> where
T: 'static, [src]
T: 'static,
Removes entity’s component from this storage.
pub fn delete(&mut self, entity: EntityId) -> bool where
T: 'static, [src]
T: 'static,
Deletes entity’s component from this storage.
impl<T> SparseSet<T>[src]
pub fn is_inserted(&self, entity: EntityId) -> bool[src]
Returns true if entity’s component was inserted since the last clear_inserted or clear_all_inserted call.
Returns false if entity does not have a component in this storage.
pub fn is_modified(&self, entity: EntityId) -> bool[src]
Returns true if entity’s component was modified since the last clear_modified or clear_all_modified call.
Returns false if entity does not have a component in this storage.
pub fn is_inserted_or_modified(&self, entity: EntityId) -> bool[src]
Returns true if entity’s component was inserted or modified since the last clear call.
Returns false if entity does not have a component in this storage.
pub fn deleted(&self) -> &[(EntityId, T)][src]
Returns the deleted components of a storage tracking deletion.
Panics
- Storage does not track deletion. Start tracking by calling
track_deletionortrack_all.
pub fn removed(&self) -> &[EntityId][src]
Returns the ids of removed components of a storage tracking removal.
Panics
- Storage does not track removal. Start tracking by calling
track_removalortrack_all.
pub fn removed_or_deleted(&self) -> impl Iterator<Item = EntityId> + '_[src]
Returns the ids of removed or deleted components of a storage tracking removal and/or deletion.
Panics
- Storage does not track removal nor deletion. Start tracking by calling
track_removal,track_deletionortrack_all.
pub fn take_deleted(&mut self) -> Vec<(EntityId, T)>[src]
Takes ownership of the deleted components of a storage tracking deletion.
Panics
- Storage does not track deletion. Start tracking by calling
track_deletionortrack_all.
pub fn take_removed(&mut self) -> Vec<EntityId>[src]
Takes ownership of the ids of removed components of a storage tracking removal.
Panics
- Storage does not track removal. Start tracking by calling
track_removalortrack_all.
pub fn take_removed_and_deleted(
&mut self
) -> (Vec<EntityId>, Vec<(EntityId, T)>)[src]
&mut self
) -> (Vec<EntityId>, Vec<(EntityId, T)>)
Takes ownership of the removed and deleted components of a storage tracking removal and/or deletion.
Panics
- Storage does not track removal nor deletion. Start tracking by calling
track_removal,track_deletionortrack_all.
pub fn clear_inserted(&mut self, entity: EntityId)[src]
Removes the inserted flag on entity’s component.
Panics
- Storage does not track insertion. Start tracking by calling
track_insertionortrack_all.
pub fn clear_all_inserted(&mut self)[src]
Removes the inserted flag on all components of this storage.
Panics
- Storage does not track insertion. Start tracking by calling
track_insertionortrack_all.
pub fn clear_modified(&mut self, entity: EntityId)[src]
Removes the modified flag on entity’s component.
Panics
- Storage does not track modification. Start tracking by calling
track_modificationortrack_all.
pub fn clear_all_modified(&mut self)[src]
Removes the modified flag on all components of this storage.
Panics
- Storage does not track modification. Start tracking by calling
track_modificationortrack_all.
pub fn clear_inserted_and_modified(&mut self, entity: EntityId)[src]
Removes the inserted and modified flags on entity’s component.
Panics
- Storage does not track insertion not modification. Start tracking by calling
track_insertion,track_modificationortrack_all.
pub fn clear_all_inserted_and_modified(&mut self)[src]
Removes the inserted and modified flags on all components of this storage.
Panics
- Storage does not track insertion not modification. Start tracking by calling
track_insertion,track_modificationortrack_all.
pub fn track_insertion(&mut self) -> &mut Self[src]
Flags components when they are inserted.
To check the flag use is_inserted, is_inserted_or_modified or iterate over the storage after calling inserted.
To clear the flag use clear_inserted or clear_all_inserted.
pub fn track_modification(&mut self) -> &mut Self[src]
Flags components when they are modified. Will not flag components already flagged inserted.
To check the flag use is_modified, is_inserted_or_modified or iterate over the storage after calling modified.
To clear the flag use clear_modified or clear_all_modified.
pub fn track_deletion(&mut self) -> &mut Self[src]
Stores components and their EntityId when they are deleted.
You can access them with deleted or removed_or_deleted.
You can clear them and get back a Vec with take_deleted or take_removed_and_deleted.
pub fn track_removal(&mut self) -> &mut Self[src]
Stores EntityId of deleted components.
You can access them with removed or removed_or_deleted.
You can clear them and get back a Vec with take_removed or take_removed_and_deleted.
pub fn track_all(&mut self)[src]
Flags component insertion, modification, deletion and removal.
Same as calling track_insertion, track_modification, track_deletion and track_removal.
pub fn is_tracking_insertion(&self) -> bool[src]
Returns true if the storage tracks insertion.
pub fn is_tracking_modification(&self) -> bool[src]
Returns true if the storage tracks modification.
pub fn is_tracking_deletion(&self) -> bool[src]
Returns true if the storage tracks deletion.
pub fn is_tracking_removal(&self) -> bool[src]
Returns true if the storage tracks removal.
pub fn is_tracking_any(&self) -> bool[src]
Returns true if the storage tracks insertion, modification, deletion or removal.
impl<T> SparseSet<T>[src]
pub fn reserve(&mut self, additional: usize)[src]
Reserves memory for at least additional components. Adding components can still allocate though.
pub fn clear(&mut self)[src]
Deletes all components in this storage.
pub fn apply<R, F: FnOnce(&mut T, &T) -> R>(
&mut self,
a: EntityId,
b: EntityId,
f: F
) -> R[src]
&mut self,
a: EntityId,
b: EntityId,
f: F
) -> R
Applies the given function f to the entities a and b.
The two entities shouldn’t point to the same component.
Panics
- MissingComponent - if one of the entity doesn’t have any component in the storage.
- IdenticalIds - if the two entities point to the same component.
pub fn apply_mut<R, F: FnOnce(&mut T, &mut T) -> R>(
&mut self,
a: EntityId,
b: EntityId,
f: F
) -> R[src]
&mut self,
a: EntityId,
b: EntityId,
f: F
) -> R
Applies the given function f to the entities a and b.
The two entities shouldn’t point to the same component.
Panics
- MissingComponent - if one of the entity doesn’t have any component in the storage.
- IdenticalIds - if the two entities point to the same component.
pub fn drain(&mut self) -> SparseSetDrain<'_, T>ⓘNotable traits for SparseSetDrain<'a, T>
impl<'a, T> Iterator for SparseSetDrain<'a, T> type Item = T;[src]
Notable traits for SparseSetDrain<'a, T>
impl<'a, T> Iterator for SparseSetDrain<'a, T> type Item = T;Creates a draining iterator that empties the storage and yields the removed items.
pub fn sort_unstable_by<F: FnMut(&T, &T) -> Ordering>(&mut self, compare: F)[src]
Sorts the SparseSet with a comparator function, but may not preserve the order of equal elements.
impl<T: Ord> SparseSet<T>[src]
pub fn sort_unstable(&mut self)[src]
Sorts the SparseSet, but may not preserve the order of equal elements.
Trait Implementations
impl<'a, T> AsMut<SparseSet<T>> for ViewMut<'a, T>[src]
impl<'a, T> AsRef<SparseSet<T>> for View<'a, T>[src]
impl<'a, T> AsRef<SparseSet<T>> for ViewMut<'a, T>[src]
impl<T> Index<EntityId> for SparseSet<T>[src]
type Output = T
The returned type after indexing.
fn index(&self, entity: EntityId) -> &Self::Output[src]
impl<T> IndexMut<EntityId> for SparseSet<T>[src]
impl<T: 'static> Storage for SparseSet<T>[src]
fn delete(&mut self, entity: EntityId)[src]
fn clear(&mut self)[src]
fn memory_usage(&self) -> Option<StorageMemoryUsage>[src]
fn sparse_array(&self) -> Option<&SparseArray<[EntityId; 32]>>[src]
fn any(&self) -> &dyn Any[src]
fn any_mut(&mut self) -> &mut dyn Any[src]
fn name(&self) -> Cow<'static, str>[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for SparseSet<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for SparseSet<T> where
T: Send,
T: Send,
impl<T> Sync for SparseSet<T> where
T: Sync,
T: Sync,
impl<T> Unpin for SparseSet<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for SparseSet<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,