SsoHashMap in rustc_data_structures::sso - Rust (original) (raw)
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.
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.
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.
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
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
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.