use core::hash::{BuildHasher, BuildHasherDefault};
pub use hashbrown::hash_map::Entry;
use nohash_hasher::BuildNoHashHasher;
pub use nohash_hasher::IsEnabled as ValidAsIdentityHash;
pub type DefaultHashBuilder = BuildHasherDefault<ahash::AHasher>;
pub type HashMap<K, V, S = DefaultHashBuilder> = hashbrown::HashMap<K, V, S>;
pub type HashSet<T, S = DefaultHashBuilder> = hashbrown::HashSet<T, S>;
pub type IntMap<K, V> = HashMap<K, V, BuildNoHashHasher<K>>;
pub type IntSet<K> = HashSet<K, BuildNoHashHasher<K>>;
pub trait HashCollectionExt {
fn new() -> Self;
fn with_capacity(capacity: usize) -> Self;
}
impl<K, V, S: BuildHasher + Default> HashCollectionExt for HashMap<K, V, S> {
fn new() -> Self {
HashMap::with_hasher(S::default())
}
fn with_capacity(capacity: usize) -> Self {
HashMap::with_capacity_and_hasher(capacity, S::default())
}
}
impl<K, S: BuildHasher + Default> HashCollectionExt for HashSet<K, S> {
fn new() -> Self {
HashSet::with_hasher(S::default())
}
fn with_capacity(capacity: usize) -> Self {
HashSet::with_capacity_and_hasher(capacity, S::default())
}
}