pub struct ConcurrentHashMap<K, V> { /* private fields */ }Expand description
A concurrent map that can be used to store key-value pairs.
§Examples
use handy::collections::{ConcurrentHashMap, Map};
let map: ConcurrentHashMap<u32, &'static str> = ConcurrentHashMap::new();§Errors
ConcurrentCollectionError::Poison: The lock is poisoned
Trait Implementations§
Source§impl<K, V> Default for ConcurrentHashMap<K, V>
impl<K, V> Default for ConcurrentHashMap<K, V>
Source§impl<K, V> Map<K, V> for ConcurrentHashMap<K, V>
impl<K, V> Map<K, V> for ConcurrentHashMap<K, V>
Source§fn new() -> Self
fn new() -> Self
Creates a new empty crate::collections::ConcurrentHashMap
§Examples
use handy::collections::{ConcurrentHashMap, Map};
let map: ConcurrentHashMap<&'static str, &'static str> = ConcurrentHashMap::new();Source§fn insert(&self, key: K, value: V) -> Result<(), ConcurrentCollectionError>
fn insert(&self, key: K, value: V) -> Result<(), ConcurrentCollectionError>
Inserts a key-value pair into the map.
§Examples
use handy::collections::{ConcurrentHashMap, Map};
let map: ConcurrentHashMap<&'static str, &'static str> = ConcurrentHashMap::new();
map.insert("key", "value").unwrap();§Errors
ConcurrentCollectionError::Poison: The lock is poisoned
Source§fn get(&self, key: &K) -> Option<V>
fn get(&self, key: &K) -> Option<V>
Retrieves a value from the map.
§Examples
use handy::collections::{ConcurrentHashMap, Map};
let map: ConcurrentHashMap<&'static str, &'static str> = ConcurrentHashMap::new();
map.get(&"key").unwrap();Source§fn remove(&self, key: &K) -> Option<V>
fn remove(&self, key: &K) -> Option<V>
Removes a key-value pair from the map.
§Examples
use handy::collections::{ConcurrentHashMap, Map};
let map: ConcurrentHashMap<&'static str, &'static str> = ConcurrentHashMap::new();
map.insert("key", "value").unwrap();
map.remove(&"key").unwrap();Source§fn len(&self) -> usize
fn len(&self) -> usize
Returns the number of key-value pairs in the map.
§Examples
use handy::collections::{ConcurrentHashMap, Map};
let map: ConcurrentHashMap<&'static str, &'static str> = ConcurrentHashMap::new();
map.insert("key", "value").unwrap();
assert_eq!(map.len(), 1);Source§fn is_empty(&self) -> bool
fn is_empty(&self) -> bool
Returns true if the map contains no key-value pairs.
§Examples
use handy::collections::{ConcurrentHashMap, Map};
let map: ConcurrentHashMap<&'static str, &'static str> = ConcurrentHashMap::new();
assert!(map.is_empty());
map.insert("key", "value").unwrap();
assert!(!map.is_empty());Source§fn contains_key(&self, key: &K) -> bool
fn contains_key(&self, key: &K) -> bool
Returns true if the map contains the specified key.
§Examples
use handy::collections::{ConcurrentHashMap, Map};
let map: ConcurrentHashMap<&'static str, &'static str> = ConcurrentHashMap::new();
map.insert("key", "value").unwrap();
assert!(map.contains_key(&"key"));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>
impl<K, V> Sync for ConcurrentHashMap<K, V>
impl<K, V> Unpin for ConcurrentHashMap<K, V>
impl<K, V> UnsafeUnpin for ConcurrentHashMap<K, V>
impl<K, V> UnwindSafe for ConcurrentHashMap<K, V>
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
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>
Converts
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>
Converts
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