Struct slotmapvec::SlotMapVec

source ·
pub struct SlotMapVec<T> { /* private fields */ }
Expand description

Slot map: array storage with persistent indices

See module documentation for more details.

Implementations

Construct a new, empty SlotMapVec.

The function does not allocate.

Examples
let slotmap :SlotMapVec<i32> = SlotMapVec::new();

Construct a new SlotMapVec with the specified capacity.

Returns the number of values the map can store without reallocating.

Returns the number of stored values.

Returns true if no values are stored in the map.

Return an iterator over all elements of the map along with their index.

Examples
let mut map = SlotMapVec::new();

for i in 0..3 {
  map.insert(i);
}

let mut i = 0;
for (idx,val) in map.iter() {
  assert_eq!(*val, i);
  i += 1;
}

Return an iterator over mutable references to all elements of the map along with their index.

Examples
let mut map = SlotMapVec::new();

for i in 0..3 {
  map.insert(i);
}

let mut i = 0;
for (idx,val) in map.iter_mut() {
  *val *= 2;
  assert_eq!(*val, i);
  i += 2;
}

Returns a reference to the value associated with the given key.

If the given key is not associated with a values, then None is returned.

Returns a mutable reference to the value associated with the given key.

If the given key is not associated with a values, then None is returned.

Insert a value into the map, returning the index to the value.

The returned index will always refer uniquely to the inserted value (though it may be mutated), even after objects have been deleted and inserted into the same storage slot.

Examples
let mut map = SlotMapVec::new();
let key = map.insert("hello");
assert_eq!(map[key], "hello");

Removes and returs the value associated with the given key.

The key is never reused in this map, except if the underlying storage type overflows.

Return true if a value is associated with the given key.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. 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

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.