pub struct CountedHashMap<K, V, S = DefaultHashBuilder> { /* private fields */ }Implementations§
Source§impl<K, V, S> CountedHashMap<K, V, S>
impl<K, V, S> CountedHashMap<K, V, S>
pub fn with_hasher(hasher: S) -> Self
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn find<Q>(&self, q: &Q) -> Option<CountedHandle<'static>>
pub fn contains_key<Q>(&self, q: &Q) -> bool
Sourcepub fn insert(
&mut self,
key: K,
value: V,
) -> Result<CountedHandle<'static>, InsertError>
pub fn insert( &mut self, key: K, value: V, ) -> Result<CountedHandle<'static>, InsertError>
Insert a new key -> value and mint a token for the returned handle.
Sourcepub fn get(&self, h: &CountedHandle<'_>) -> CountedHandle<'static>
pub fn get(&self, h: &CountedHandle<'_>) -> CountedHandle<'static>
Mint another token for the same entry; used to clone a counted handle.
Sourcepub fn insert_with<F>(
&mut self,
key: K,
default: F,
) -> Result<CountedHandle<'static>, InsertError>where
F: FnOnce() -> V,
pub fn insert_with<F>(
&mut self,
key: K,
default: F,
) -> Result<CountedHandle<'static>, InsertError>where
F: FnOnce() -> V,
Insert using a lazy value constructor; only calls default() when inserting.
Sourcepub fn put(&mut self, h: CountedHandle<'_>) -> PutResult<K, V>
pub fn put(&mut self, h: CountedHandle<'_>) -> PutResult<K, V>
Return a token for an entry; removes and returns (K, V) when count hits zero.
pub fn iter(&self) -> impl Iterator<Item = (Handle, &K, &V)>
pub fn iter_mut(&mut self) -> impl Iterator<Item = (Handle, &K, &mut V)>
Trait Implementations§
Auto Trait Implementations§
impl<K, V, S = WyHashRandomState> !Freeze for CountedHashMap<K, V, S>
impl<K, V, S = WyHashRandomState> !RefUnwindSafe for CountedHashMap<K, V, S>
impl<K, V, S = WyHashRandomState> !Send for CountedHashMap<K, V, S>
impl<K, V, S = WyHashRandomState> !Sync for CountedHashMap<K, V, S>
impl<K, V, S> Unpin for CountedHashMap<K, V, S>
impl<K, V, S> UnwindSafe for CountedHashMap<K, V, S>
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
Mutably borrows from an owned value. Read more