[][src]Struct sid::IdFreeList

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]

pub fn new() -> IdFreeList<ID, Data, C>[src]

Create an empty list.

pub fn with_capacity(size: usize) -> IdFreeList<ID, Data, C>[src]

Create an empty list with a preallocated buffer.

pub fn add(&mut self, elt: Data) -> ID[src]

Add an element to the list and return the id pointing to it

pub fn push(&mut self, elt: Data) -> ID[src]

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.

pub fn remove(&mut self, id: ID)[src]

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.

pub fn count(&self) -> usize[src]

Count the elements in O(N).

pub fn has_id(&self, id: ID) -> bool[src]

Return true if the id is found in the list in O(N).

pub fn is_empty(&self) -> bool[src]

Return true if there is no element in the list.

pub fn clear(&mut self)[src]

Remove all elements from the list and clears the storage. Note that this will Drop the elements if Data implements Drop.

pub fn next_id(&self, id: ID) -> Option<ID>[src]

Return the next id in the list.

pub fn previous_id(&self, id: ID) -> Option<ID>[src]

Return the previous id in the list.

pub fn first_id(&self) -> Option<ID>[src]

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.

impl<ID: Identifier, Data, C: NullId<ID>> IndexMut<ID> for IdFreeList<ID, Data, C>[src]

Auto Trait Implementations

impl<ID, Data, C> Unpin for IdFreeList<ID, Data, C> where
    C: Unpin,
    Data: Unpin,
    ID: Unpin

impl<ID, Data, C> Send for IdFreeList<ID, Data, C> where
    C: Send,
    Data: Send,
    ID: Send

impl<ID, Data, C> Sync for IdFreeList<ID, Data, C> where
    C: Sync,
    Data: Sync,
    ID: Sync

Blanket Implementations

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> Into<U> for T where
    U: From<T>, 
[src]

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

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.

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

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

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