pub struct HashMapRef<'map, K, V, S = DefaultHashBuilder> { /* private fields */ }
Expand description
A reference to a HashMap
, constructed with HashMap::pin
or HashMap::with_guard
.
The current thread will be pinned for the duration of this reference. Keep in mind that this prevents the collection of garbage generated by the map.
Implementations§
Source§impl<K, V, S> HashMapRef<'_, K, V, S>
impl<K, V, S> HashMapRef<'_, K, V, S>
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of entries in the map.
See also HashMap::len
.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true
if the map is empty. Otherwise returns false
.
See also HashMap::is_empty
.
Sourcepub fn iter(&self) -> Iter<'_, K, V> ⓘ
pub fn iter(&self) -> Iter<'_, K, V> ⓘ
An iterator visiting all key-value pairs in arbitrary order.
The iterator element type is (&'g K, &'g V)
.
See also HashMap::iter
.
Sourcepub fn keys(&self) -> Keys<'_, K, V> ⓘ
pub fn keys(&self) -> Keys<'_, K, V> ⓘ
An iterator visiting all keys in arbitrary order.
The iterator element type is &'g K
.
See also HashMap::keys
.
Sourcepub fn values(&self) -> Values<'_, K, V> ⓘ
pub fn values(&self) -> Values<'_, K, V> ⓘ
An iterator visiting all values in arbitrary order.
The iterator element type is &'g V
.
See also HashMap::values
.
Source§impl<K, V, S> HashMapRef<'_, K, V, S>
impl<K, V, S> HashMapRef<'_, K, V, S>
Sourcepub fn reserve(&self, additional: usize)
pub fn reserve(&self, additional: usize)
Tries to reserve capacity for at least additional
more elements to be inserted in the
HashMap
.
The collection may reserve more space to avoid frequent reallocations.
See also HashMap::reserve
.
Source§impl<K, V, S> HashMapRef<'_, K, V, S>
impl<K, V, S> HashMapRef<'_, K, V, S>
Sourcepub fn contains_key<Q>(&self, key: &Q) -> bool
pub fn contains_key<Q>(&self, key: &Q) -> bool
Returns true
if the map contains a value for the specified key.
See also HashMap::contains_key
.
Source§impl<K, V, S> HashMapRef<'_, K, V, S>
impl<K, V, S> HashMapRef<'_, K, V, S>
Sourcepub fn clear(&self)
pub fn clear(&self)
Clears the map, removing all key-value pairs.
See also HashMap::clear
.
Source§impl<K, V, S> HashMapRef<'_, K, V, S>
impl<K, V, S> HashMapRef<'_, K, V, S>
Sourcepub fn insert(&self, key: K, value: V) -> Option<&V>
pub fn insert(&self, key: K, value: V) -> Option<&V>
Inserts a key-value pair into the map.
See also HashMap::insert
.
Sourcepub fn try_insert(&self, key: K, value: V) -> Result<&V, TryInsertError<'_, V>>
pub fn try_insert(&self, key: K, value: V) -> Result<&V, TryInsertError<'_, V>>
Inserts a key-value pair into the map unless the key already exists.
See also HashMap::try_insert
.
Sourcepub fn compute_if_present<'g, Q, F>(
&'g self,
key: &Q,
remapping_function: F,
) -> Option<&'g V>
pub fn compute_if_present<'g, Q, F>( &'g self, key: &Q, remapping_function: F, ) -> Option<&'g V>
If the value for the specified key
is present, attempts to
compute a new mapping given the key and its current mapped value.
See also HashMap::compute_if_present
.
Sourcepub fn remove<'g, Q>(&'g self, key: &Q) -> Option<&'g V>
pub fn remove<'g, Q>(&'g self, key: &Q) -> Option<&'g V>
Removes a key-value pair from the map, and returns the removed value (if any).
See also HashMap::remove
.
Sourcepub fn remove_entry<'g, Q>(&'g self, key: &Q) -> Option<(&'g K, &'g V)>
pub fn remove_entry<'g, Q>(&'g self, key: &Q) -> Option<(&'g K, &'g V)>
Removes a key from the map, returning the stored key and value if the key was previously in the map.
See also HashMap::remove_entry
.
Sourcepub fn retain<F>(&self, f: F)
pub fn retain<F>(&self, f: F)
Retains only the elements specified by the predicate.
See also HashMap::retain
.
Sourcepub fn retain_force<F>(&self, f: F)
pub fn retain_force<F>(&self, f: F)
Retains only the elements specified by the predicate.
See also HashMap::retain_force
.