pub struct SeqMap<K: Hash + PartialEq + Eq + Copy + Clone + Send + Sync + 'static, V: Copy + Clone + Send + Sync + 'static, H: Hasher + Default = DefaultHasher> { /* private fields */ }Expand description
A concurrent, lock-free hash map implementation that can sustain rapid expansion and high contention on every key, while allowing for concurrent reads and writes.
Based on the interior mutability provided by SeqArray, this map uses open addressing
with linear probing to provide a highly concurrent map interface, and can be safely shared
and passed between threads.
without issue.
use seqmap::SeqMap;
let map = SeqMap::<u64, u8>::new();
map.insert(1, 42);
map.insert(2, 43);
std::thread::scope(|s| {
s.spawn(|| {
assert_eq!(map.get(1), Some(42));
map.insert(3, 100);
});
s.spawn(|| {
assert_eq!(map.get(2), Some(43));
map.insert(4, 101);
});
});
assert_eq!(map.get(1), Some(42));
assert_eq!(map.get(2), Some(43));
assert_eq!(map.get(3), Some(100));
assert_eq!(map.get(4), Some(101));Implementations§
Source§impl<K: Hash + PartialEq + Eq + Copy + Clone + Send + Sync + 'static, V: Copy + Clone + Send + Sync + 'static, H: Hasher + Default> SeqMap<K, V, H>
impl<K: Hash + PartialEq + Eq + Copy + Clone + Send + Sync + 'static, V: Copy + Clone + Send + Sync + 'static, H: Hasher + Default> SeqMap<K, V, H>
Sourcepub fn with_capacity(size: usize) -> Self
pub fn with_capacity(size: usize) -> Self
Creates a new SeqMap with the specified initial capacity.
Trait Implementations§
Source§impl<K: Clone + Hash + PartialEq + Eq + Copy + Clone + Send + Sync + 'static, V: Clone + Copy + Clone + Send + Sync + 'static, H: Clone + Hasher + Default> Clone for SeqMap<K, V, H>
impl<K: Clone + Hash + PartialEq + Eq + Copy + Clone + Send + Sync + 'static, V: Clone + Copy + Clone + Send + Sync + 'static, H: Clone + Hasher + Default> Clone for SeqMap<K, V, H>
Source§impl<K: Default + Hash + PartialEq + Eq + Copy + Clone + Send + Sync + 'static, V: Default + Copy + Clone + Send + Sync + 'static, H: Default + Hasher + Default> Default for SeqMap<K, V, H>
impl<K: Default + Hash + PartialEq + Eq + Copy + Clone + Send + Sync + 'static, V: Default + Copy + Clone + Send + Sync + 'static, H: Default + Hasher + Default> Default for SeqMap<K, V, H>
Source§impl<K: PartialEq + Hash + PartialEq + Eq + Copy + Clone + Send + Sync + 'static, V: PartialEq + Copy + Clone + Send + Sync + 'static, H: PartialEq + Hasher + Default> PartialEq for SeqMap<K, V, H>
impl<K: PartialEq + Hash + PartialEq + Eq + Copy + Clone + Send + Sync + 'static, V: PartialEq + Copy + Clone + Send + Sync + 'static, H: PartialEq + Hasher + Default> PartialEq for SeqMap<K, V, H>
impl<K: Eq + Hash + PartialEq + Eq + Copy + Clone + Send + Sync + 'static, V: Eq + Copy + Clone + Send + Sync + 'static, H: Eq + Hasher + Default> Eq for SeqMap<K, V, H>
impl<K: Hash + PartialEq + Eq + Copy + Clone + Send + Sync + 'static, V: Copy + Clone + Send + Sync + 'static, H: Hasher + Default> StructuralPartialEq for SeqMap<K, V, H>
Auto Trait Implementations§
impl<K, V, H = DefaultHasher> !Freeze for SeqMap<K, V, H>
impl<K, V, H = DefaultHasher> !RefUnwindSafe for SeqMap<K, V, H>
impl<K, V, H> Send for SeqMap<K, V, H>where
H: Send,
impl<K, V, H> Sync for SeqMap<K, V, H>where
H: Sync,
impl<K, V, H> Unpin for SeqMap<K, V, H>where
H: Unpin,
impl<K, V, H = DefaultHasher> !UnwindSafe for SeqMap<K, V, H>
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