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