Struct sid::IdVec

source ·
pub struct IdVec<ID: Identifier, T> { /* private fields */ }
Expand description

Similar to Vec except that it is indexed using an Id rather than an usize index. if the stored type implements Default, IdVec can also use the set(…) method which can grow the vector to accomodate for the requested id.

Implementations§

Create an empty IdVec

Create an IdVec with preallocated storage

Create an IdVec by recycling a Vec and its content.

Consume the IdVec and create a Vec.

Exposes the internal Vec.

Number of elements in the IdVec

Returns true if the vector contains no elements.

Extracts a slice containing the entire vector.

Extracts a mutable slice containing the entire vector.

Return the nth element of the IdVec using an usize index rather than an Id (à la Vec).

Return the nth element of the IdVec using an usize index rather than an Id (à la Vec).

Iterate over the elements of the IdVec

Iterate over the elements of the IdVec

Add an element to the IdVec and return its Id. This method can cause the storage to be reallocated.

Inserts an element at position id within the vector, shifting all elements after it to the right.

Insert several elements by cloning them starting at position ’id` and shifting all elements after them to the right.

Insert several elements by cloning them starting at position ’id` and shifting all elements after them to the right.

Clones and appends all elements in a slice to the vector.

Clones and appends all elements in a slice to the vector.

Reserves capacity for at least additional more elements to be inserted in the given vector.

Shrinks the capacity of the vector as much as possible.

Drop all of the contained elements and clear the IdVec’s storage.

Removes and returns the element at position index within the vector, shifting all elements after it to the left.

Removes an element from the vector and returns it. The removed element is replaced by the last element of the vector.

Set the value for a certain Id, possibly adding default values if the Id’s index is Greater than the size of the underlying vector.

Creates an IdVec with an n elements initialized to Default::default.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
The returned type after indexing.
Performs the indexing (container[index]) operation. Read more
Performs the mutable indexing (container[index]) operation. Read more
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
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
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

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.