Struct sid_vec::IdFreeList
[−]
[src]
pub struct IdFreeList<ID: Identifier, Data, C: NullId<ID>> { /* fields omitted */ }
A linked list stored in contiguous memory allowing random access through ids.
Methods
impl<ID: Identifier, Data, C: NullId<ID>> IdFreeList<ID, Data, C>
[src]
fn new() -> IdFreeList<ID, Data, C>
Create an empty list.
fn with_capacity(size: usize) -> IdFreeList<ID, Data, C>
Create an empty list with a preallocated buffer.
fn add(&mut self, elt: Data) -> ID
Add an element to the list and return the id pointing to it
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.
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.
fn count(&self) -> usize
Count the elements in O(N).
fn has_id(&self, id: ID) -> bool
Return true if the id is found in the list in O(N).
fn is_empty(&self) -> bool
Return true if there is no element in the list.
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.
fn next_id(&self, id: ID) -> Option<ID>
Return the next id in the list.
fn previous_id(&self, id: ID) -> Option<ID>
Return the previous id in the list.
fn first_id(&self) -> Option<ID>
Return the first id in the list.
Trait Implementations
impl<ID: Identifier, Data, C: NullId<ID>> Index<ID> for IdFreeList<ID, Data, C>
[src]
type Output = Data
The returned type after indexing
fn index<'l>(&'l self, id: ID) -> &'l Data
The method for the indexing (container[index]
) operation
impl<ID: Identifier, Data, C: NullId<ID>> IndexMut<ID> for IdFreeList<ID, Data, C>
[src]
fn index_mut<'l>(&'l mut self, id: ID) -> &'l mut Data
The method for the mutable indexing (container[index]
) operation