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]

Constructs a new RandomState that is initialized with random keys.

Trait Implementations

impl<T: FastHash> BuildHasher for RandomState<T>
[src]

Type of the hasher that will be created.

Creates a new hasher. Read more

impl<T: FastHash> Default for RandomState<T>
[src]

Returns the "default value" for a type. Read more