pub struct SyncHashMapB<K, V>{ /* private fields */ }Expand description
Bucketed hash map, distributing data to multiple sub-maps to improve concurrency performance 分桶哈希映射,将数据分散到多个子映射中以提高并发性能
Implementations§
Source§impl<K, V> SyncHashMapB<K, V>
impl<K, V> SyncHashMapB<K, V>
Sourcepub fn new(bucket_count: Option<usize>) -> Self
pub fn new(bucket_count: Option<usize>) -> Self
Create a new bucketed hash map 创建新的分桶哈希映射
§Arguments
bucket_count- Number of buckets, defaults to 10 if Nonebucket_count- 分桶数量,如果为None则默认为10
§Examples
use fast_able::map_hash::buckets::SyncHashMapB;
let map = SyncHashMapB::new(None);
map.insert(1, "a");
map.insert(2, "b");
assert_eq!(*map.get(&1).unwrap(), "a");
assert_eq!(*map.get(&2).unwrap(), "b");
assert!(map.get(&3).is_none());Sourcepub fn insert_mut(&mut self, k: K, v: V) -> Option<V>
pub fn insert_mut(&mut self, k: K, v: V) -> Option<V>
Insert operation under mutable reference 可变引用下的插入操作
Sourcepub fn get(&self, k: &K) -> Option<MapReadGuard<'_, V>>
pub fn get(&self, k: &K) -> Option<MapReadGuard<'_, V>>
Get a reference to the value corresponding to the key, protected by read lock (value no lock) 获取键对应的值引用,使用读锁保护 (值无锁)
Returns a ReadGuardNoLock that holds the read lock until the guard is dropped.
返回一个 ReadGuardNoLock,在 guard 被释放前持有读锁。
Sourcepub fn get_mut(&self, k: &K) -> Option<WriteGuard<'_, V>>
pub fn get_mut(&self, k: &K) -> Option<WriteGuard<'_, V>>
Get a mutable reference to the value corresponding to the key, protected by write lock 获取键对应的可变值引用,使用写锁保护
Returns a WriteGuard that holds the write lock until the guard is dropped, ensuring concurrent access safety.
返回一个 WriteGuard,在 guard 被释放前持有写锁,保证并发访问安全。
Sourcepub fn bucket_count(&self) -> usize
pub fn bucket_count(&self) -> usize
Get the number of buckets 获取桶数量
Trait Implementations§
Source§impl<K, V: Clone> Clone for SyncHashMapB<K, V>
impl<K, V: Clone> Clone for SyncHashMapB<K, V>
Source§fn clone(&self) -> SyncHashMapB<K, V>
fn clone(&self) -> SyncHashMapB<K, V>
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<K, V: Debug> Debug for SyncHashMapB<K, V>
impl<K, V: Debug> Debug for SyncHashMapB<K, V>
Auto Trait Implementations§
impl<K, V> Freeze for SyncHashMapB<K, V>
impl<K, V> !RefUnwindSafe for SyncHashMapB<K, V>
impl<K, V> Send for SyncHashMapB<K, V>
impl<K, V> Sync for SyncHashMapB<K, V>
impl<K, V> Unpin for SyncHashMapB<K, V>
impl<K, V> UnwindSafe for SyncHashMapB<K, V>where
K: UnwindSafe,
V: UnwindSafe,
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)