Struct scc::HashIndex [−][src]
A scalable concurrent hash index implementation.
scc::HashIndex is a concurrent hash index data structure that is aimed at read-most workloads.
Implementations
impl<K, V, H> HashIndex<K, V, H> where
K: Clone + Eq + Hash + Sync,
V: Clone + Sync,
H: BuildHasher,
[src]
K: Clone + Eq + Hash + Sync,
V: Clone + Sync,
H: BuildHasher,
pub fn new(capacity: usize, build_hasher: H) -> HashIndex<K, V, H>
[src]
Creates an empty HashIndex instance with the given capacity and build hasher.
The actual capacity is equal to or greater than the given capacity. It is recommended to give a capacity value that is larger than 16 * the number of threads to access the HashMap.
Panics
Panics if memory allocation fails.
Examples
use scc::HashIndex; use std::collections::hash_map::RandomState;
pub fn insert(&self, key: K, value: V) -> Result<(), (K, V)>
[src]
Inserts a key-value pair into the HashIndex.
Returns an error with the given key-value pair attached if the key exists.
Panics
Panics if memory allocation fails, or the number of entries in the target cell reaches u32::MAX.
Examples
use scc::HashIndex;
pub fn remove(&self, _tkey: &K) -> bool
[src]
pub fn read<R, F: FnOnce(&K, &V) -> R>(&self, _key: &K, _f: F) -> Option<R>
[src]
pub fn retain<F: Fn(&K, &V) -> bool>(&self, _f: F) -> (usize, usize)
[src]
Retains the key-value pairs that satisfy the given predicate.
It returns the number of entries remaining and removed.
Examples
use scc::HashIndex;
pub fn clear(&self) -> usize
[src]
pub fn len<F: FnOnce(usize) -> usize>(&self, _f: F) -> usize
[src]
Returns an estimated size of the HashIndex.
The given function determines the sampling size. A function returning a fixed number larger than u16::MAX yields around 99% accuracy.
Examples
use scc::HashIndex;
pub fn capacity(&self) -> usize
[src]
pub fn hasher(&self) -> &H
[src]
Returns a reference to its build hasher.
Examples
use scc::HashIndex; use std::collections::hash_map::RandomState; let hashindex: HashIndex<u64, u32, _> = Default::default(); let result: &RandomState = hashindex.hasher();
pub fn iter(&self) -> Visitor<'_, K, V, H>
[src]
Returns a Visitor.
It is guaranteed to go through all the key-value pairs pertaining in the HashIndex at the moment, however the same key-value pair can be visited more than once if the HashIndex is being resized.
Examples
use scc::HashIndex;
Trait Implementations
impl<K, V> Default for HashIndex<K, V, RandomState> where
K: Clone + Eq + Hash + Sync,
V: Clone + Sync,
[src]
K: Clone + Eq + Hash + Sync,
V: Clone + Sync,
fn default() -> Self
[src]
Creates a HashIndex instance with the default parameters.
The default hash builder is RandomState, and the default capacity is 256.
Panics
Panics if memory allocation fails.
use scc::HashIndex;
impl<K, V, H> Drop for HashIndex<K, V, H> where
K: Clone + Eq + Hash + Sync,
V: Clone + Sync,
H: BuildHasher,
[src]
K: Clone + Eq + Hash + Sync,
V: Clone + Sync,
H: BuildHasher,
Auto Trait Implementations
impl<K, V, H> RefUnwindSafe for HashIndex<K, V, H> where
H: RefUnwindSafe,
K: RefUnwindSafe,
V: RefUnwindSafe,
[src]
H: RefUnwindSafe,
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V, H> Send for HashIndex<K, V, H> where
H: Send,
K: Send,
V: Send,
[src]
H: Send,
K: Send,
V: Send,
impl<K, V, H> Sync for HashIndex<K, V, H> where
H: Sync,
[src]
H: Sync,
impl<K, V, H> Unpin for HashIndex<K, V, H> where
H: Unpin,
K: Unpin,
V: Unpin,
[src]
H: Unpin,
K: Unpin,
V: Unpin,
impl<K, V, H> UnwindSafe for HashIndex<K, V, H> where
H: UnwindSafe,
K: UnwindSafe,
V: UnwindSafe,
[src]
H: UnwindSafe,
K: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
[src]
pub const ALIGN: usize
[src]
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
[src]
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
[src]
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
[src]
pub unsafe fn drop(ptr: usize)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,