Struct ConcurrentHashMap

Source
pub struct ConcurrentHashMap<K, V> { /* private fields */ }

Implementations§

Source§

impl<K, V> ConcurrentHashMap<K, V>

Source

pub fn new() -> Self

Source

pub fn get_inner(&self) -> Arc<RwLock<HashMap<K, V>>>

Source

pub fn get_inner_rl(&self) -> RwLockReadGuard<'_, HashMap<K, V>>

Source

pub fn get_inner_wl(&self) -> RwLockWriteGuard<'_, HashMap<K, V>>

Source

pub fn get_or_insert( &self, key: &K, value_gen_fn: impl Fn(&K) -> Result<V, SmallError>, ) -> Result<V, SmallError>
where K: Eq + Hash + Clone, V: Clone,

Source

pub fn alter_value( &self, key: &K, alter_fn: impl Fn(&mut V) -> Result<(), SmallError>, ) -> Result<(), SmallError>
where K: Eq + Hash + Clone, V: Clone + Default,

Source

pub fn exact_or_empty(&self, k: &K, v: &V) -> bool
where K: Eq + Hash, V: Eq,

Return true if map[&k] == v, or map[&k] is not exist.

Return false if map[&k] != v.

Source

pub fn clear(&self)

Source

pub fn remove(&self, key: &K) -> Option<V>
where K: Eq + Hash,

Source

pub fn insert(&self, key: K, value: V) -> Option<V>
where K: Eq + Hash,

Source

pub fn keys(&self) -> Vec<K>
where K: Eq + Hash + Clone,

Auto Trait Implementations§

§

impl<K, V> Freeze for ConcurrentHashMap<K, V>

§

impl<K, V> RefUnwindSafe for ConcurrentHashMap<K, V>

§

impl<K, V> Send for ConcurrentHashMap<K, V>
where K: Send + Sync, V: Send + Sync,

§

impl<K, V> Sync for ConcurrentHashMap<K, V>
where K: Send + Sync, V: Send + Sync,

§

impl<K, V> Unpin for ConcurrentHashMap<K, V>

§

impl<K, V> UnwindSafe for ConcurrentHashMap<K, V>

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.