CountedHashMap

Struct CountedHashMap 

Source
pub struct CountedHashMap<K, V, S = DefaultHashBuilder> { /* private fields */ }

Implementations§

Source§

impl<K, V> CountedHashMap<K, V>
where K: Eq + Hash,

Source

pub fn new() -> Self

Source§

impl<K, V, S> CountedHashMap<K, V, S>
where K: Eq + Hash, S: BuildHasher + Clone + Default,

Source

pub fn with_hasher(hasher: S) -> Self

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn find<Q>(&self, q: &Q) -> Option<CountedHandle<'static>>
where K: Borrow<Q>, Q: ?Sized + Hash + Eq,

Source

pub fn contains_key<Q>(&self, q: &Q) -> bool
where K: Borrow<Q>, Q: ?Sized + Hash + Eq,

Source

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.

Source

pub fn get(&self, h: &CountedHandle<'_>) -> CountedHandle<'static>

Mint another token for the same entry; used to clone a counted handle.

Source

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.

Source

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.

Source

pub fn iter(&self) -> impl Iterator<Item = (Handle, &K, &V)>

Source

pub fn iter_mut(&mut self) -> impl Iterator<Item = (Handle, &K, &mut V)>

Trait Implementations§

Source§

impl<K, V> Default for CountedHashMap<K, V>
where K: Eq + Hash,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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>
where S: Unpin, K: Unpin, V: Unpin,

§

impl<K, V, S> UnwindSafe for CountedHashMap<K, V, S>
where S: UnwindSafe, K: UnwindSafe, V: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.