pub struct SyncIndexMap<K: Eq + Hash, V> { /* private fields */ }
Expand description
this sync map used to many reader,writer less.space-for-time strategy
Implementations§
Source§impl<K, V> SyncIndexMap<K, V>
impl<K, V> SyncIndexMap<K, V>
pub fn new_arc() -> Arc<Self>
pub fn new() -> Self
pub fn with_capacity(capacity: usize) -> Self
pub fn with_map(map: Map<K, V>) -> Self
pub fn insert(&self, k: K, v: V) -> Option<V>
pub fn insert_mut(&mut self, k: K, v: V) -> Option<V>
pub fn remove(&self, k: &K) -> Option<V>
pub fn remove_mut(&mut self, k: &K) -> Option<V>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn clear(&self)
pub fn clear_mut(&mut self)
pub fn shrink_to_fit(&self)
pub fn shrink_to_fit_mut(&mut self)
pub fn from(map: Map<K, V>) -> Self
Sourcepub fn get<Q>(&self, k: &Q) -> Option<&V>
pub fn get<Q>(&self, k: &Q) -> Option<&V>
Returns a reference to the value corresponding to the key.
The key may be any borrowed form of the map’s key type, but
Hash
and Eq
on the borrowed form must match those for
the key type.
Since reading a map is unlocked, it is very fast
test bench_sync_hash_map_read … bench: 8 ns/iter (+/- 0)
§Examples
use dark_std::sync::{SyncIndexMap};
let mut map = SyncIndexMap::new();
map.insert_mut(1, "a");
assert_eq!(*map.get(&1).unwrap(), "a");
assert_eq!(map.get(&2).is_none(), true);
pub fn get_mut(&self, k: &K) -> Option<HashMapRefMut<'_, K, V>>
pub fn contains_key(&self, x: &K) -> boolwhere
K: PartialEq,
pub fn iter(&self) -> MapIter<'_, K, V>
pub fn iter_mut(&self) -> HashIterMut<'_, K, V> ⓘ
pub fn into_iter(self) -> MapIntoIter<K, V>
pub fn dirty_ref(&self) -> &Map<K, V>
pub fn into_inner(self) -> Map<K, V>
Trait Implementations§
Source§impl<K, V> Debug for SyncIndexMap<K, V>
impl<K, V> Debug for SyncIndexMap<K, V>
Source§impl<'de, K, V> Deserialize<'de> for SyncIndexMap<K, V>
impl<'de, K, V> Deserialize<'de> for SyncIndexMap<K, V>
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<K, V> Display for SyncIndexMap<K, V>
impl<K, V> Display for SyncIndexMap<K, V>
Source§impl<K, V> Index<&K> for SyncIndexMap<K, V>
impl<K, V> Index<&K> for SyncIndexMap<K, V>
Source§impl<'a, K, V> IntoIterator for &'a SyncIndexMap<K, V>
impl<'a, K, V> IntoIterator for &'a SyncIndexMap<K, V>
Source§impl<K, V> IntoIterator for SyncIndexMap<K, V>
impl<K, V> IntoIterator for SyncIndexMap<K, V>
Source§impl<K, V> Serialize for SyncIndexMap<K, V>
impl<K, V> Serialize for SyncIndexMap<K, V>
impl<K: Eq + Hash, V> Send for SyncIndexMap<K, V>
this is safety, dirty mutex ensure
impl<K: Eq + Hash, V> Sync for SyncIndexMap<K, V>
this is safety, dirty mutex ensure
Auto Trait Implementations§
impl<K, V> !Freeze for SyncIndexMap<K, V>
impl<K, V> !RefUnwindSafe for SyncIndexMap<K, V>
impl<K, V> Unpin for SyncIndexMap<K, V>
impl<K, V> UnwindSafe for SyncIndexMap<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
Mutably borrows from an owned value. Read more