Struct scc::HashIndex[][src]

pub struct HashIndex<K, V, H> where
    K: Clone + Eq + Hash + Sync,
    V: Clone + Sync,
    H: BuildHasher
{ /* fields omitted */ }

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]

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]

Removes a key-value pair.

Returns false if the key does not exist.

Examples

use scc::HashIndex;

pub fn read<R, F: FnOnce(&K, &V) -> R>(&self, _key: &K, _f: F) -> Option<R>[src]

Reads a key-value pair.

Errors

Returns None if the key does not exist.

Examples

use scc::HashIndex;

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]

Clears all the key-value pairs.

Examples

use scc::HashIndex;

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]

Returns the capacity of the HashIndex.

Examples

use scc::HashIndex;

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]

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]

Auto Trait Implementations

impl<K, V, H> RefUnwindSafe for HashIndex<K, V, H> where
    H: RefUnwindSafe,
    K: RefUnwindSafe,
    V: RefUnwindSafe
[src]

impl<K, V, H> Send for HashIndex<K, V, H> where
    H: Send,
    K: Send,
    V: Send
[src]

impl<K, V, H> Sync for HashIndex<K, V, H> where
    H: Sync
[src]

impl<K, V, H> Unpin for HashIndex<K, V, H> where
    H: Unpin,
    K: Unpin,
    V: Unpin
[src]

impl<K, V, H> UnwindSafe for HashIndex<K, V, H> where
    H: UnwindSafe,
    K: UnwindSafe,
    V: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T[src]

type Init = T

The type for initializers.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.