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
sourceimpl<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>ⓘNotable traits for Iter<'g, K, V>impl<'g, K, V> Iterator for Iter<'g, K, V> type Item = (&'g K, &'g V);
pub fn iter(&self) -> Iter<'_, K, V>ⓘNotable traits for Iter<'g, K, V>impl<'g, K, V> Iterator for Iter<'g, K, V> type Item = (&'g K, &'g V);
An iterator visiting all key-value pairs in arbitrary order.
The iterator element type is (&'g K, &'g V)
.
See also HashMap::iter
.
sourceimpl<K, V, S> HashMapRef<'_, K, V, S> where
K: Clone + Ord,
impl<K, V, S> HashMapRef<'_, K, V, S> where
K: Clone + Ord,
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
.
sourceimpl<K, V, S> HashMapRef<'_, K, V, S> where
K: Hash + Ord,
S: BuildHasher,
impl<K, V, S> HashMapRef<'_, K, V, S> where
K: Hash + Ord,
S: BuildHasher,
sourcepub fn contains_key<Q>(&self, key: &Q) -> bool where
K: Borrow<Q>,
Q: ?Sized + Hash + Ord,
pub fn contains_key<Q>(&self, key: &Q) -> bool where
K: Borrow<Q>,
Q: ?Sized + Hash + Ord,
Returns true
if the map contains a value for the specified key.
See also HashMap::contains_key
.
sourceimpl<K, V, S> HashMapRef<'_, K, V, S> where
K: Clone + Ord,
impl<K, V, S> HashMapRef<'_, K, V, S> where
K: Clone + Ord,
sourcepub fn clear(&self)
pub fn clear(&self)
Clears the map, removing all key-value pairs.
See also HashMap::clear
.
sourceimpl<K, V, S> HashMapRef<'_, K, V, S> where
K: Sync + Send + Clone + Hash + Ord,
V: Sync + Send,
S: BuildHasher,
impl<K, V, S> HashMapRef<'_, K, V, S> where
K: Sync + Send + Clone + Hash + Ord,
V: Sync + Send,
S: BuildHasher,
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> where
K: Borrow<Q>,
Q: ?Sized + Hash + Ord,
F: FnOnce(&K, &V) -> Option<V>,
pub fn compute_if_present<'g, Q, F>(
&'g self,
key: &Q,
remapping_function: F
) -> Option<&'g V> where
K: Borrow<Q>,
Q: ?Sized + Hash + Ord,
F: FnOnce(&K, &V) -> Option<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> where
K: Borrow<Q>,
Q: ?Sized + Hash + Ord,
pub fn remove<'g, Q>(&'g self, key: &Q) -> Option<&'g V> where
K: Borrow<Q>,
Q: ?Sized + Hash + Ord,
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)> where
K: Borrow<Q>,
Q: ?Sized + Hash + Ord,
pub fn remove_entry<'g, Q>(&'g self, key: &Q) -> Option<(&'g K, &'g V)> where
K: Borrow<Q>,
Q: ?Sized + Hash + Ord,
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) where
F: FnMut(&K, &V) -> bool,
pub fn retain<F>(&self, f: F) where
F: FnMut(&K, &V) -> bool,
Retains only the elements specified by the predicate.
See also HashMap::retain
.
sourcepub fn retain_force<F>(&self, f: F) where
F: FnMut(&K, &V) -> bool,
pub fn retain_force<F>(&self, f: F) where
F: FnMut(&K, &V) -> bool,
Retains only the elements specified by the predicate.
See also HashMap::retain_force
.
Trait Implementations
sourceimpl<K, V, S> Clone for HashMapRef<'_, K, V, S>
impl<K, V, S> Clone for HashMapRef<'_, K, V, S>
sourceimpl<K, V, S> Debug for HashMapRef<'_, K, V, S> where
K: Debug,
V: Debug,
impl<K, V, S> Debug for HashMapRef<'_, K, V, S> where
K: Debug,
V: Debug,
sourceimpl<K, Q, V, S> Index<&'_ Q> for HashMapRef<'_, K, V, S> where
K: Hash + Ord + Borrow<Q>,
Q: ?Sized + Hash + Ord,
S: BuildHasher,
impl<K, Q, V, S> Index<&'_ Q> for HashMapRef<'_, K, V, S> where
K: Hash + Ord + Borrow<Q>,
Q: ?Sized + Hash + Ord,
S: BuildHasher,
sourceimpl<'g, K, V, S> IntoIterator for &'g HashMapRef<'_, K, V, S>
impl<'g, K, V, S> IntoIterator for &'g HashMapRef<'_, K, V, S>
sourceimpl<K, V, S> PartialEq<HashMap<K, V, S>> for HashMapRef<'_, K, V, S> where
K: Hash + Ord,
V: PartialEq,
S: BuildHasher,
impl<K, V, S> PartialEq<HashMap<K, V, S>> for HashMapRef<'_, K, V, S> where
K: Hash + Ord,
V: PartialEq,
S: BuildHasher,
sourceimpl<K, V, S> PartialEq<HashMapRef<'_, K, V, S>> for HashMapRef<'_, K, V, S> where
K: Hash + Ord,
V: PartialEq,
S: BuildHasher,
impl<K, V, S> PartialEq<HashMapRef<'_, K, V, S>> for HashMapRef<'_, K, V, S> where
K: Hash + Ord,
V: PartialEq,
S: BuildHasher,
sourceimpl<K, V, S> PartialEq<HashMapRef<'_, K, V, S>> for HashMap<K, V, S> where
K: Hash + Ord,
V: PartialEq,
S: BuildHasher,
impl<K, V, S> PartialEq<HashMapRef<'_, K, V, S>> for HashMap<K, V, S> where
K: Hash + Ord,
V: PartialEq,
S: BuildHasher,
impl<K, V, S> Eq for HashMapRef<'_, K, V, S> where
K: Hash + Ord,
V: Eq,
S: BuildHasher,
Auto Trait Implementations
impl<'map, K, V, S = RandomState> !RefUnwindSafe for HashMapRef<'map, K, V, S>
impl<'map, K, V, S = RandomState> !Send for HashMapRef<'map, K, V, S>
impl<'map, K, V, S = RandomState> !Sync for HashMapRef<'map, K, V, S>
impl<'map, K, V, S> Unpin for HashMapRef<'map, K, V, S>
impl<'map, K, V, S = RandomState> !UnwindSafe for HashMapRef<'map, K, V, S>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more