Struct sid::IdFreeList
source · pub struct IdFreeList<ID: Identifier, Data, C: NullId<ID>> { /* private fields */ }
Expand description
A linked list stored in contiguous memory allowing random access through ids.
Implementations§
source§impl<ID: Identifier, Data, C: NullId<ID>> IdFreeList<ID, Data, C>
impl<ID: Identifier, Data, C: NullId<ID>> IdFreeList<ID, Data, C>
sourcepub fn new() -> IdFreeList<ID, Data, C>
pub fn new() -> IdFreeList<ID, Data, C>
Create an empty list.
sourcepub fn with_capacity(size: usize) -> IdFreeList<ID, Data, C>
pub fn with_capacity(size: usize) -> IdFreeList<ID, Data, C>
Create an empty list with a preallocated buffer.
sourcepub fn add(&mut self, elt: Data) -> ID
pub fn add(&mut self, elt: Data) -> ID
Add an element to the list and return the id pointing to it
sourcepub fn push(&mut self, elt: Data) -> ID
pub fn push(&mut self, elt: Data) -> ID
Add an element to the list at the end of the vector storage (without attempting to occupy a slot from the free-list). This means that repeated calls to push without calls to add or remove will produce contiguous indices.
sourcepub fn remove(&mut self, id: ID)
pub fn remove(&mut self, id: ID)
Remove a given element from the list and place the slot in the free-list. Note that this does not attempt to drop the element.
sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Remove all elements from the list and clears the storage. Note that this will Drop the elements if Data implements Drop.
sourcepub fn previous_id(&self, id: ID) -> Option<ID>
pub fn previous_id(&self, id: ID) -> Option<ID>
Return the previous id in the list.
Trait Implementations§
source§impl<ID: Identifier, Data, C: NullId<ID>> Index<ID> for IdFreeList<ID, Data, C>
impl<ID: Identifier, Data, C: NullId<ID>> Index<ID> for IdFreeList<ID, Data, C>
source§impl<ID: Identifier, Data, C: NullId<ID>> IndexMut<ID> for IdFreeList<ID, Data, C>
impl<ID: Identifier, Data, C: NullId<ID>> IndexMut<ID> for IdFreeList<ID, Data, C>
source§fn index_mut<'l>(&'l mut self, id: ID) -> &'l mut Data
fn index_mut<'l>(&'l mut self, id: ID) -> &'l mut Data
Performs the mutable indexing (
container[index]
) operation. Read moreAuto Trait Implementations§
impl<ID, Data, C> RefUnwindSafe for IdFreeList<ID, Data, C>
impl<ID, Data, C> Send for IdFreeList<ID, Data, C>
impl<ID, Data, C> Sync for IdFreeList<ID, Data, C>
impl<ID, Data, C> Unpin for IdFreeList<ID, Data, C>
impl<ID, Data, C> UnwindSafe for IdFreeList<ID, Data, C>
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