use std::collections::{HashMap, HashSet};
use std::hash::{BuildHasherDefault, Hasher};
#[derive(Default)]
pub(crate) struct IntHasher(u64);
impl Hasher for IntHasher {
fn write(&mut self, bytes: &[u8]) {
let mut hash = 0xcbf2_9ce4_8422_2325u64;
for &byte in bytes {
hash ^= u64::from(byte);
hash = hash.wrapping_mul(0x0000_0100_0000_01B3);
}
self.0 = hash;
}
fn write_u32(&mut self, i: u32) {
self.0 = u64::from(i);
}
fn write_u64(&mut self, i: u64) {
self.0 = i;
}
fn write_usize(&mut self, i: usize) {
self.0 = i as u64;
}
fn finish(&self) -> u64 {
let mut x = self.0;
x ^= x >> 30;
x = x.wrapping_mul(0xbf58_476d_1ce4_e5b9);
x ^= x >> 27;
x = x.wrapping_mul(0x94d0_49bb_1331_11eb);
x ^ (x >> 31)
}
}
pub(crate) type IntMap<K, V> = HashMap<K, V, BuildHasherDefault<IntHasher>>;
pub(crate) type IntSet<T> = HashSet<T, BuildHasherDefault<IntHasher>>;