pub enum SsoHashMap<K, V> {
    Array(ArrayVec<(K, V), SSO_ARRAY_SIZE>),
    Map(FxHashMap<K, V>),
}
Expand description

Small-storage-optimized implementation of a map.

Stores elements in a small array up to a certain length and switches to HashMap when that length is exceeded.

Variants§

§

Array(ArrayVec<(K, V), SSO_ARRAY_SIZE>)

§

Map(FxHashMap<K, V>)

Implementations§

Creates an empty SsoHashMap.

Creates an empty SsoHashMap with the specified capacity.

Clears the map, removing all key-value pairs. Keeps the allocated memory for reuse.

Returns the number of elements the map can hold without reallocating.

Returns the number of elements in the map.

Returns true if the map contains no elements.

An iterator visiting all key-value pairs in arbitrary order. The iterator element type is (&'a K, &'a V).

An iterator visiting all key-value pairs in arbitrary order, with mutable references to the values. The iterator element type is (&'a K, &'a mut V).

An iterator visiting all keys in arbitrary order. The iterator element type is &'a K.

An iterator visiting all values in arbitrary order. The iterator element type is &'a V.

An iterator visiting all values mutably in arbitrary order. The iterator element type is &'a mut V.

Clears the map, returning all key-value pairs as an iterator. Keeps the allocated memory for reuse.

Changes underlying storage from array to hashmap if array is full.

Reserves capacity for at least additional more elements to be inserted in the SsoHashMap. The collection may reserve more space to avoid frequent reallocations.

Shrinks the capacity of the map as much as possible. It will drop down as much as possible while maintaining the internal rules and possibly leaving some space in accordance with the resize policy.

Retains only the elements specified by the predicate.

Inserts a key-value pair into the map.

If the map did not have this key present, None is returned.

If the map did have this key present, the value is updated, and the old value is returned. The key is not updated, though; this matters for types that can be == without being identical. See the [module-level documentation] for more.

Removes a key from the map, returning the value at the key if the key was previously in the map.

source

pub fn remove_entry(&mut self, key: &K) -> Option<(K, V)>

Removes a key from the map, returning the stored key and value if the key was previously in the map.

Returns a reference to the value corresponding to the key.

Returns a mutable reference to the value corresponding to the key.

Returns the key-value pair corresponding to the supplied key.

Returns true if the map contains a value for the specified key.

Gets the given key’s corresponding entry in the map for in-place manipulation.

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
Extends a collection with the contents of an iterator. Read more
🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Extends a collection with the contents of an iterator. Read more
🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Creates a value from an iterator. Read more
The returned type after indexing.
Performs the indexing (container[index]) operation. Read more
Which kind of iterator are we turning this into?
The type of the elements being iterated over.
Creates an iterator from a value. Read more
Which kind of iterator are we turning this into?
The type of the elements being iterated over.
Creates an iterator from a value. Read more
Which kind of iterator are we turning this into?
The type of the elements being iterated over.
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.

Layout§

Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.