use std::hash::BuildHasherDefault;
use std::hash::Hasher;
const K: u64 = 0x517c_c1b7_2722_0a95;
#[derive(Default)]
pub struct FxHasher {
hash: u64,
}
impl Hasher for FxHasher {
#[inline]
fn finish(&self) -> u64 {
self.hash
}
#[inline]
fn write(&mut self, bytes: &[u8]) {
for &b in bytes {
self.hash = (self.hash.rotate_left(5) ^ b as u64).wrapping_mul(K);
}
}
#[inline]
fn write_u32(&mut self, i: u32) {
self.hash = (self.hash.rotate_left(5) ^ i as u64).wrapping_mul(K);
}
#[inline]
fn write_u64(&mut self, i: u64) {
self.hash = (self.hash.rotate_left(5) ^ i).wrapping_mul(K);
}
}
pub type FxBuildHasher = BuildHasherDefault<FxHasher>;
pub type MapHasher = hashbrown::DefaultHashBuilder;
pub type Map<K, V> = hashbrown::HashMap<K, V, MapHasher>;
#[inline]
pub fn map<K, V>() -> Map<K, V> {
Map::with_hasher(MapHasher::default())
}
#[inline]
pub fn map_with_capacity<K, V>(cap: usize) -> Map<K, V> {
Map::with_capacity_and_hasher(cap, MapHasher::default())
}