Struct flurry::HashMapRef
source · 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
.
Trait Implementations§
source§impl<K, V, S> Clone for HashMapRef<'_, K, V, S>
impl<K, V, S> Clone for HashMapRef<'_, K, V, S>
source§impl<K, V, S> Debug for HashMapRef<'_, K, V, S>
impl<K, V, S> Debug for HashMapRef<'_, K, V, S>
source§impl<K, Q, V, S> Index<&Q> for HashMapRef<'_, K, V, S>
impl<K, Q, V, S> Index<&Q> for HashMapRef<'_, K, V, S>
source§impl<'g, K, V, S> IntoIterator for &'g HashMapRef<'_, K, V, S>
impl<'g, K, V, S> IntoIterator for &'g HashMapRef<'_, K, V, S>
source§impl<K, V, S> PartialEq<HashMap<K, V, S>> for HashMapRef<'_, K, V, S>
impl<K, V, S> PartialEq<HashMap<K, V, S>> for HashMapRef<'_, K, V, S>
source§impl<K, V, S> PartialEq<HashMapRef<'_, K, V, S>> for HashMap<K, V, S>
impl<K, V, S> PartialEq<HashMapRef<'_, K, V, S>> for HashMap<K, V, S>
source§fn eq(&self, other: &HashMapRef<'_, K, V, S>) -> bool
fn eq(&self, other: &HashMapRef<'_, K, V, S>) -> bool
self
and other
values to be equal, and is used
by ==
.