Skip to main content

SparseSet

Struct SparseSet 

Source
pub struct SparseSet<T, Idx, S, const TRACK: bool = true>
where T: Copy, Idx: IndexLike + Tagged, S: DiffStore<T, Idx, TRACK>,
{ /* private fields */ }
Expand description

Semi-persistent sparse set with stable IDs.

Implementations§

Source§

impl<T, Idx, S, const TRACK: bool> SparseSet<T, Idx, S, TRACK>
where T: Copy, Idx: IndexLike + Tagged, S: DiffStore<T, Idx, TRACK>,

Source

pub fn len(&self) -> Idx

Source

pub fn is_empty(&self) -> bool

Source

pub fn contains(&self, id: Idx) -> bool

Liveness test. Returns exactly contains_spec(id).

Source

pub fn get(&self, id: Idx) -> T

Value of a live id (through the stable indirection).

Source

pub fn set(&mut self, id: Idx, value: T)

Overwrite a live id’s value in place (position and id unchanged).

Source

pub fn remove(&mut self, id: Idx)

Remove a live id. Swap-removes its dense slot with the last element and parks the freed id at the new boundary indices[n-1] (the first free slot), preserving the permutation by a transposition.

Source

pub fn remove_value(&mut self, val: &T) -> bool
where T: PartialEq,

Remove the first live entry whose VALUE equals val (production remove_value parity: linear scan of the dense region, then the verified remove on the id found at that position).

Source

pub fn data(&self) -> &Vec<T, Idx, S, TRACK>

Read-only access to the dense value vector (production data() parity: exposes the packed live values for iteration).

Source

pub fn can_add(&self) -> bool

Exec counterpart of add’s three-column capacity precondition.

Source

pub fn try_add(&mut self, value: T) -> Result<Idx, ContainerError>

Total add.

Source

pub fn try_get(&self, id: Idx) -> Result<T, ContainerError>

Total get: Err(IndexOutOfBounds) for an id that is not live.

Source

pub fn try_mark( &mut self, shrink: ShrinkPolicy, ) -> Result<SparseSetToken, ContainerError>

Total mark: TRACK first, then the six column headrooms as one answer.

Source

pub fn is_valid_token(&self, token: &SparseSetToken) -> bool

Whether the composite token is restorable now. Every constituent must be restorable, which is the validation half of aggregate atomicity.

Source

pub fn restore(&mut self, token: SparseSetToken)
where T: Default, Idx: Default,

Source§

impl<T, Idx, const TRACK: bool> SparseSet<T, Idx, ParallelStore<T, Idx>, TRACK>
where T: Copy, Idx: IndexLike + Tagged,

Source

pub fn new() -> SparseSet<T, Idx, ParallelStore<T, Idx>, TRACK>

Empty sparse set over a ParallelStore (any T: Copy; production SparseSet::new parity).

Source§

impl<T, Idx, const TRACK: bool> SparseSet<T, Idx, InlineStore<T, Idx>, TRACK>
where T: Tagged + Copy, Idx: IndexLike + Tagged,

Source

pub fn new_inline() -> SparseSet<T, Idx, InlineStore<T, Idx>, TRACK>

Empty sparse set over an InlineStore (T: Tagged; production SparseSet::new_inline parity).

Trait Implementations§

Source§

impl<T, Idx, const TRACK: bool> Default for SparseSet<T, Idx, ParallelStore<T, Idx>, TRACK>
where T: Copy, Idx: IndexLike + Tagged,

Source§

fn default() -> SparseSet<T, Idx, ParallelStore<T, Idx>, TRACK>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T, Idx, S, const TRACK: bool> Freeze for SparseSet<T, Idx, S, TRACK>
where Vec<T, Idx, S, TRACK>: Freeze, Vec<Idx, Idx, InlineStore<Idx, Idx>, TRACK>: Freeze,

§

impl<T, Idx, S, const TRACK: bool> RefUnwindSafe for SparseSet<T, Idx, S, TRACK>
where Vec<T, Idx, S, TRACK>: RefUnwindSafe, Vec<Idx, Idx, InlineStore<Idx, Idx>, TRACK>: RefUnwindSafe,

§

impl<T, Idx, S, const TRACK: bool> Send for SparseSet<T, Idx, S, TRACK>
where Vec<T, Idx, S, TRACK>: Send, Vec<Idx, Idx, InlineStore<Idx, Idx>, TRACK>: Send,

§

impl<T, Idx, S, const TRACK: bool> Sync for SparseSet<T, Idx, S, TRACK>
where Vec<T, Idx, S, TRACK>: Sync, Vec<Idx, Idx, InlineStore<Idx, Idx>, TRACK>: Sync,

§

impl<T, Idx, S, const TRACK: bool> Unpin for SparseSet<T, Idx, S, TRACK>
where Vec<T, Idx, S, TRACK>: Unpin, Vec<Idx, Idx, InlineStore<Idx, Idx>, TRACK>: Unpin,

§

impl<T, Idx, S, const TRACK: bool> UnsafeUnpin for SparseSet<T, Idx, S, TRACK>
where Vec<T, Idx, S, TRACK>: UnsafeUnpin, Vec<Idx, Idx, InlineStore<Idx, Idx>, TRACK>: UnsafeUnpin,

§

impl<T, Idx, S, const TRACK: bool> UnwindSafe for SparseSet<T, Idx, S, TRACK>
where Vec<T, Idx, S, TRACK>: UnwindSafe, Vec<Idx, Idx, InlineStore<Idx, Idx>, TRACK>: 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, 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.