Struct shipyard::SparseSet[][src]

pub struct SparseSet<T> { /* fields omitted */ }

Default component storage.

Implementations

impl<T> SparseSet<T>[src]

pub fn as_slice(&self) -> &[T][src]

Returns a slice of all the components in this storage.

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]

Removes entity’s component from this storage.

pub fn delete(&mut self, entity: EntityId) -> bool where
    T: 'static, 
[src]

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

pub fn removed(&self) -> &[EntityId][src]

Returns the ids of removed components of a storage tracking removal.

Panics

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

pub fn take_deleted(&mut self) -> Vec<(EntityId, T)>[src]

Takes ownership of the deleted components of a storage tracking deletion.

Panics

pub fn take_removed(&mut self) -> Vec<EntityId>[src]

Takes ownership of the ids of removed components of a storage tracking removal.

Panics

pub fn take_removed_and_deleted(
    &mut self
) -> (Vec<EntityId>, Vec<(EntityId, T)>)
[src]

Takes ownership of the removed and deleted components of a storage tracking removal and/or deletion.

Panics

pub fn clear_inserted(&mut self, entity: EntityId)[src]

Removes the inserted flag on entity’s component.

Panics

pub fn clear_all_inserted(&mut self)[src]

Removes the inserted flag on all components of this storage.

Panics

pub fn clear_modified(&mut self, entity: EntityId)[src]

Removes the modified flag on entity’s component.

Panics

pub fn clear_all_modified(&mut self)[src]

Removes the modified flag on all components of this storage.

Panics

pub fn clear_inserted_and_modified(&mut self, entity: EntityId)[src]

Removes the inserted and modified flags on entity’s component.

Panics

pub fn clear_all_inserted_and_modified(&mut self)[src]

Removes the inserted and modified flags on all components of this storage.

Panics

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]

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]

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]

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.

impl<T> IndexMut<EntityId> for SparseSet<T>[src]

impl<T: 'static> Storage for SparseSet<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for SparseSet<T> where
    T: RefUnwindSafe

impl<T> Send for SparseSet<T> where
    T: Send

impl<T> Sync for SparseSet<T> where
    T: Sync

impl<T> Unpin for SparseSet<T> where
    T: Unpin

impl<T> UnwindSafe for SparseSet<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.