pub struct ConcurrentElasticMap<K, V> { /* private fields */ }Expand description
A thread-safe hash table with adaptive probing strategy.
This implementation uses atomic operations to ensure thread safety without traditional locks, allowing for high concurrency with minimal contention. The adaptive probing strategy dynamically adjusts step sizes based on occupancy patterns.
Implementations§
Source§impl<K, V> ConcurrentElasticMap<K, V>
impl<K, V> ConcurrentElasticMap<K, V>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new ConcurrentElasticMap with the default initial capacity and parameters
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates a new ConcurrentElasticMap with the specified initial capacity
Sourcepub fn get_index<Q: ?Sized + Hash>(&self, key: &Q) -> usize
pub fn get_index<Q: ?Sized + Hash>(&self, key: &Q) -> usize
Computes the index in the buckets array for a given key
§Panics
This function will panic if unable to acquire the read lock on the buckets.
Sourcepub fn set_occupancy_threshold(&self, threshold: usize)
pub fn set_occupancy_threshold(&self, threshold: usize)
Provide a way to configure the occupancy threshold
Sourcepub fn set_load_factor_threshold(&self, threshold: f64)
pub fn set_load_factor_threshold(&self, threshold: f64)
Provide a way to configure the load factor threshold
Sourcepub fn iter(&self) -> Iter<'_, K, V>
pub fn iter(&self) -> Iter<'_, K, V>
Returns an iterator over the key-value pairs
§Panics
This function will panic if unable to acquire the read lock on buckets.
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the capacity (number of buckets) in the map
§Panics
This function will panic if unable to acquire the read lock on buckets.
Sourcepub fn load_factor(&self) -> f64
pub fn load_factor(&self) -> f64
Returns the current load factor of the map
§Panics
This function will panic if unable to acquire the read lock on buckets.