use crate::inner::RandomState;
pub type RapidHashMap<K, V, const AVALANCHE: bool, const SPONGE: bool, const COMPACT: bool = false, const PROTECTED: bool = false> = std::collections::HashMap<K, V, RandomState<AVALANCHE, SPONGE, COMPACT, PROTECTED>>;
pub type RapidHashSet<K, const AVALANCHE: bool, const SPONGE: bool, const COMPACT: bool = false, const PROTECTED: bool = false> = std::collections::HashSet<K, RandomState<AVALANCHE, SPONGE, COMPACT, PROTECTED>>;
pub trait HashMapExt<const AVALANCHE: bool, const SPONGE: bool, const COMPACT: bool = false, const PROTECTED: bool = false> {
fn new() -> Self;
fn with_capacity(capacity: usize) -> Self;
}
impl<K, V, const AVALANCHE: bool, const SPONGE: bool, const COMPACT: bool, const PROTECTED: bool> HashMapExt<AVALANCHE, SPONGE, COMPACT, PROTECTED> for RapidHashMap<K, V, AVALANCHE, SPONGE, COMPACT, PROTECTED> {
fn new() -> Self {
RapidHashMap::default()
}
fn with_capacity(capacity: usize) -> Self {
RapidHashMap::with_capacity_and_hasher(capacity, RandomState::<AVALANCHE, SPONGE, COMPACT, PROTECTED>::default())
}
}
pub trait HashSetExt<const AVALANCHE: bool, const SPONGE: bool, const COMPACT: bool = false, const PROTECTED: bool = false> {
fn new() -> Self;
fn with_capacity(capacity: usize) -> Self;
}
impl<K, const AVALANCHE: bool, const SPONGE: bool, const COMPACT: bool, const PROTECTED: bool> HashSetExt<AVALANCHE, SPONGE, COMPACT, PROTECTED> for RapidHashSet<K, AVALANCHE, SPONGE, COMPACT, PROTECTED> {
fn new() -> Self {
RapidHashSet::default()
}
fn with_capacity(capacity: usize) -> Self {
RapidHashSet::with_capacity_and_hasher(capacity, RandomState::<AVALANCHE, SPONGE, COMPACT, PROTECTED>::default())
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_hashmap_size() {
assert_eq!(core::mem::size_of::<RapidHashMap<u32, u32, true, true, false, false>>(), 40);
}
}