Struct shipyard::SparseSet

source ·
pub struct SparseSet<T: Component, Track: Tracking = <T as Component>::Tracking> { /* private fields */ }
Expand description

Default component storage.

Implementations§

source§

impl<T: Component> SparseSet<T>

source

pub fn new_custom_storage() -> Self

Returns a new SparseSet to be used in custom storage.

source

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

Returns a slice of all the components in this storage.

source§

impl<T: Component> SparseSet<T>

source

pub fn contains(&self, entity: EntityId) -> bool

Returns true if entity owns a component in this storage.

source

pub fn len(&self) -> usize

Returns the length of the storage.

source

pub fn is_empty(&self) -> bool

Returns true if the storage’s length is 0.

source§

impl<T: Component> SparseSet<T>

source

pub fn index_of(&self, entity: EntityId) -> Option<usize>

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.

source

pub unsafe fn index_of_unchecked(&self, entity: EntityId) -> usize

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.

source

pub fn id_at(&self, index: usize) -> Option<EntityId>

Returns the EntityId at a given index.

source§

impl<T: Component<Tracking = Deletion>> SparseSet<T, Deletion>

source

pub fn clear_all_deleted(&mut self)

Clear all deletion tracking data.

source

pub fn clear_all_deleted_older_than_timestamp( &mut self, timestamp: TrackingTimestamp, )

Clear all deletion tracking data older than some timestamp.

source

pub fn clear_all_removed_or_deleted(&mut self)

Clear all deletion and removal tracking data.

source

pub fn clear_all_removed_or_deleted_older_than_timestamp( &mut self, timestamp: TrackingTimestamp, )

Clear all deletion and removal tracking data older than some timestamp.

source§

impl<T: Component<Tracking = Removal>> SparseSet<T, Removal>

source

pub fn clear_all_removed(&mut self)

Clear all removal tracking data.

source

pub fn clear_all_removed_older_than_timestamp( &mut self, timestamp: TrackingTimestamp, )

Clear all removal tracking data older than some timestamp.

source

pub fn clear_all_removed_and_deleted(&mut self)

Clear all deletion and removal tracking data.

source

pub fn clear_all_removed_or_deleted_older_than_timestamp( &mut self, timestamp: TrackingTimestamp, )

Clear all deletion and removal tracking data older than some timestamp.

source§

impl<T: Component<Tracking = All>> SparseSet<T, All>

source

pub fn clear_all_deleted(&mut self)

Clear all deletion tracking data.

source

pub fn clear_all_deleted_older_than_timestamp( &mut self, timestamp: TrackingTimestamp, )

Clear all deletion tracking data older than some timestamp.

source

pub fn clear_all_removed(&mut self)

Clear all removal tracking data.

source

pub fn clear_all_removed_older_than_timestamp( &mut self, timestamp: TrackingTimestamp, )

Clear all removal tracking data older than some timestamp.

source

pub fn clear_all_removed_and_deleted(&mut self)

Clear all deletion and removal tracking data.

source

pub fn clear_all_removed_or_deleted_older_than_timestamp( &mut self, timestamp: TrackingTimestamp, )

Clear all deletion and removal tracking data older than some timestamp.

source§

impl<T: Component> SparseSet<T>

source

pub fn is_tracking_insertion(&self) -> bool

Returns true if the storage tracks insertion.

source

pub fn is_tracking_modification(&self) -> bool

Returns true if the storage tracks modification.

source

pub fn is_tracking_deletion(&self) -> bool

Returns true if the storage tracks deletion.

source

pub fn is_tracking_removal(&self) -> bool

Returns true if the storage tracks removal.

source

pub fn is_tracking_any(&self) -> bool

Returns true if the storage tracks insertion, modification, deletion or removal.

source§

impl<T: Component> SparseSet<T>

source

pub fn reserve(&mut self, additional: usize)

Reserves memory for at least additional components. Adding components can still allocate though.

source

pub fn sort_unstable_by<F: FnMut(&T, &T) -> Ordering>(&mut self, compare: F)

Sorts the SparseSet with a comparator function, but may not preserve the order of equal elements.

source§

impl<T: Ord + Component> SparseSet<T>

source

pub fn sort_unstable(&mut self)

Sorts the SparseSet, but may not preserve the order of equal elements.

Trait Implementations§

source§

impl<'a, T: Component> AsMut<SparseSet<T>> for ViewMut<'a, T>

source§

fn as_mut(&mut self) -> &mut SparseSet<T>

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl<'a, T: Component> AsRef<SparseSet<T>> for View<'a, T>

source§

fn as_ref(&self) -> &SparseSet<T>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<'a, T: Component> AsRef<SparseSet<T>> for ViewMut<'a, T>

source§

fn as_ref(&self) -> &SparseSet<T>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<T: Debug + Component> Debug for SparseSet<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T: 'static + Component> Storage for SparseSet<T>

source§

fn delete(&mut self, entity: EntityId, current: u32)

Deletes an entity from this storage.
source§

fn clear(&mut self, current: u32)

Deletes all components of this storage.
source§

fn memory_usage(&self) -> Option<StorageMemoryUsage>

Returns how much memory this storage uses.
source§

fn sparse_array(&self) -> Option<&SparseArray<EntityId, BUCKET_SIZE>>

Returns a SparseSet’s internal SparseArray.
source§

fn is_empty(&self) -> bool

Returns true if the storage is empty.
source§

fn clear_all_removed_or_deleted(&mut self)

Clear all deletion and removal tracking data.
source§

fn clear_all_removed_or_deleted_older_than_timestamp( &mut self, timestamp: TrackingTimestamp, )

Clear all deletion and removal tracking data older than some timestamp.
source§

fn any(&self) -> &dyn Any

Casts to &dyn Any.
source§

fn any_mut(&mut self) -> &mut dyn Any

Casts to &mut dyn Any.
source§

fn name(&self) -> Cow<'static, str>

Returns the storage’s name.

Auto Trait Implementations§

§

impl<T, Track> Freeze for SparseSet<T, Track>

§

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

§

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

§

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

§

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

§

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

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> TupleDeleteAny for T
where T: 'static + Storage + CustomDeleteAny,

source§

impl<S> TupleRetain for S
where S: 'static + Storage,

source§

fn retain(all_storages: &mut AllStorages, entity: EntityId)

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more