Struct id_vec::vec::IdVec[][src]

pub struct IdVec<T> { /* fields omitted */ }

Inserting elements into this map yields a persistent, type-safe Index to that new element. It does not try to preserve the order of the inserted items.

The IdVec does not actively try to preserve order of inserted elements, but a packed IdVec will append elements to the end of the internal vector.

Methods

impl<T> IdVec<T>
[src]

Does not allocate heap memory

Create a map containing these elements. Directly uses the specified vector, so no heap allocation is made calling this function.

Used to estimate the maximal index_value() of all ids inside this IdVec. This IdVec will not contain an id with an index value greater than or equal to this value.

Excludes deleted elements, and indices out of range

Returns if the internal vector does not contain any deleted elements

Enable the specified id to be overwritten when a new element is inserted. This does not directly deallocate the element. Make sure that no ids pointing to that element exist after this call. Ignores invalid and deleted ids.

Removes an id and the associated element. See pop_element for more information.

Removes an element from this map, returns the element: Removes the one element which is the least work to remove, the one with the highest id. May deallocate unused elements. Returns None if this map is empty.

Associate the specified element with a currently unused id. This may overwrite (thus drop) unused elements.

Return a reference to the element that this id points to

Return a mutable reference to the element that this id points to

Swap the elements pointed to. Panic on invalid Id parameter.

Removes all elements, instantly deallocating

Shrinks the internal vector itself

Reserve space for more elements, avoiding frequent reallocation

Retain only the elements specified by the predicate. May deallocate unused elements.

Make this map have a continuous flow of indices, having no wasted allocation and calling remap(old_id, new_id) for every element that has been moved to a new Id It does not preserve order of the inserted items.

Important traits for Iter<'s, T>

Used for immutable access to ids and elements

Important traits for IntoElements<T>

Iterate over the elements, consuming this IdVec

Important traits for DrainElements<'s, T>

Iterate over the elements, clearing this IdVec

Important traits for ElementIter<'s, T>

Used for immutable direct access to all used elements

Important traits for IdIter<'s, T>

Used for immutable indirect access

Important traits for OwnedIdIter<T>

Used for full mutable access, while allowing inserting and deleting while iterating. The iterator will keep an independent state, in order to un-borrow the underlying map. This may be more expensive than iter, because it needs to clone the internal set of unused ids.

Compares if two id-maps contain the same ids, ignoring elements. Complexity of O(n)

Compares if two id-maps contain the same elements, ignoring ids. Worst case complexity of O(n^2)

Worst case complexity of O(n)

Worst case complexity of O(n)

Trait Implementations

impl<T: Clone> Clone for IdVec<T>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<T: Default> Default for IdVec<T>
[src]

Returns the "default value" for a type. Read more

impl<T> FromIterator<T> for IdVec<T>
[src]

Creates a value from an iterator. Read more

impl<T> IntoIterator for IdVec<T>
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

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

Performs the conversion.

impl<T> Index<Id<T>> for IdVec<T>
[src]

The returned type after indexing.

Performs the indexing (container[index]) operation.

impl<T> IndexMut<Id<T>> for IdVec<T>
[src]

Performs the mutable indexing (container[index]) operation.

impl<T> Eq for IdVec<T> where
    T: Eq
[src]

Equality means: The same Ids pointing to the same elements, ignoring deleted elements. Complexity of O(n)

impl<T> PartialEq for IdVec<T> where
    T: PartialEq
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<T> Debug for IdVec<T> where
    T: Debug
[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl<T> Send for IdVec<T> where
    T: Send

impl<T> Sync for IdVec<T> where
    T: Sync