Struct fasthash::RandomState
[−]
[src]
pub struct RandomState<T: FastHash> { /* fields omitted */ }
RandomState
provides the default state for HashMap
or HashSet
types.
A particular instance RandomState
will create the same instances of
[Hasher
], but the hashers created by two different RandomState
instances are unlikely to produce the same result for the same values.
use std::hash::{Hash, Hasher}; use std::collections::HashMap; use fasthash::RandomState; use fasthash::city::CityHash64; let s = RandomState::<CityHash64>::new(); let mut map = HashMap::with_hasher(s); assert_eq!(map.insert(37, "a"), None); assert_eq!(map.is_empty(), false); map.insert(37, "b"); assert_eq!(map.insert(37, "c"), Some("b")); assert_eq!(map[&37], "c");
Methods
impl<T: FastHash> RandomState<T>
[src]
fn new() -> Self
Constructs a new RandomState
that is initialized with random keys.
Trait Implementations
impl<T: FastHash> BuildHasher for RandomState<T>
[src]
type Hasher = T::FastHasher
Type of the hasher that will be created.
fn build_hasher(&self) -> Self::Hasher
Creates a new hasher. Read more