pub struct RefCountedHashMap<K, V> { /* private fields */ }Expand description
A HashMap which keeps a reference count for each entry.
Implementations§
Source§impl<K: Eq + Hash, V> RefCountedHashMap<K, V>
impl<K: Eq + Hash, V> RefCountedHashMap<K, V>
Sourcepub fn insert_with<O, F: FnOnce() -> (V, O)>(
&mut self,
key: K,
f: F,
) -> InsertResult<O>
pub fn insert_with<O, F: FnOnce() -> (V, O)>( &mut self, key: K, f: F, ) -> InsertResult<O>
Increments the reference count of the entry with the given key.
If the key isn’t in the map, the given function is called to create its associated value.
Sourcepub fn remove(&mut self, key: K) -> RemoveResult<V>
pub fn remove(&mut self, key: K) -> RemoveResult<V>
Decrements the reference count of the entry with the given key.
If the reference count reaches 0, the entry will be removed and its value returned.
Sourcepub fn contains_key(&self, key: &K) -> bool
pub fn contains_key(&self, key: &K) -> bool
Returns true if the map contains a value for the specified key.
Sourcepub fn get(&self, key: &K) -> Option<&V>
pub fn get(&self, key: &K) -> Option<&V>
Returns a reference to the value corresponding to the key.
Sourcepub fn get_mut(&mut self, key: &K) -> Option<&mut V>
pub fn get_mut(&mut self, key: &K) -> Option<&mut V>
Returns a mutable reference to the value corresponding to the key.
Sourcepub fn iter_mut<'a>(
&'a mut self,
) -> impl 'a + Iterator<Item = (&'a K, &'a mut V)>
pub fn iter_mut<'a>( &'a mut self, ) -> impl 'a + Iterator<Item = (&'a K, &'a mut V)>
An iterator visiting all key-value pairs in arbitrary order, with mutable references to the values.
Sourcepub fn iter<'a>(&'a self) -> impl 'a + Iterator<Item = (&'a K, &'a V)> + Clone
pub fn iter<'a>(&'a self) -> impl 'a + Iterator<Item = (&'a K, &'a V)> + Clone
An iterator visiting all key-value pairs in arbitrary order, with non-mutable references to the values.
Sourcepub fn iter_ref_counts<'a>(
&'a self,
) -> impl 'a + Iterator<Item = (&'a K, &'a NonZeroUsize)> + Clone
pub fn iter_ref_counts<'a>( &'a self, ) -> impl 'a + Iterator<Item = (&'a K, &'a NonZeroUsize)> + Clone
An iterator visiting all keys in arbitrary order with the reference count for each key.
Trait Implementations§
Source§impl<K, V> Default for RefCountedHashMap<K, V>
impl<K, V> Default for RefCountedHashMap<K, V>
Source§fn default() -> RefCountedHashMap<K, V>
fn default() -> RefCountedHashMap<K, V>
Auto Trait Implementations§
impl<K, V> Freeze for RefCountedHashMap<K, V>
impl<K, V> RefUnwindSafe for RefCountedHashMap<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for RefCountedHashMap<K, V>
impl<K, V> Sync for RefCountedHashMap<K, V>
impl<K, V> Unpin for RefCountedHashMap<K, V>
impl<K, V> UnwindSafe for RefCountedHashMap<K, V>where
K: UnwindSafe,
V: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<O, BC> BuildableCoreContext<BC> for Owhere
O: Default,
impl<O, BC> BuildableCoreContext<BC> for Owhere
O: Default,
§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more