#![forbid(unsafe_code)]
#![warn(missing_docs)]
pub mod growth_policy;
pub mod hasher;
mod map;
mod popcount;
pub mod serialize;
mod set;
mod sparse_array;
mod sparse_hash;
pub mod sparsity;
mod util;
pub use crate::growth_policy::{GrowthPolicy, LengthError, Mod, PowerOfTwo, Prime};
pub use crate::hasher::{EqKey, FnHash, HashKey, StdEq, StdHash};
pub use crate::map::SparseMap;
pub use crate::serialize::{
Deserialize, DeserializeError, Deserializer, Serialize, Serializer,
SERIALIZATION_PROTOCOL_VERSION,
};
pub use crate::set::SparseSet;
pub use crate::sparse_array::BITMAP_NB_BITS;
pub use crate::sparsity::{High, Low, Medium, Sparsity};
pub type SparsePgMap<K, V, H = StdHash, E = StdEq, S = Medium> = SparseMap<K, V, H, E, Prime, S>;
pub type SparsePgSet<K, H = StdHash, E = StdEq, S = Medium> = SparseSet<K, H, E, Prime, S>;
use core::hash::Hash;
impl<K, V> FromIterator<(K, V)> for SparseMap<K, V>
where
K: Hash + Eq,
{
fn from_iter<I: IntoIterator<Item = (K, V)>>(iter: I) -> Self {
let mut map = SparseMap::new();
map.extend(iter);
map
}
}
impl<K, V, const N: usize> From<[(K, V); N]> for SparseMap<K, V>
where
K: Hash + Eq,
{
fn from(array: [(K, V); N]) -> Self {
array.into_iter().collect()
}
}
impl<K> FromIterator<K> for SparseSet<K>
where
K: Hash + Eq,
{
fn from_iter<I: IntoIterator<Item = K>>(iter: I) -> Self {
let mut set = SparseSet::new();
set.extend(iter);
set
}
}
impl<K, const N: usize> From<[K; N]> for SparseSet<K>
where
K: Hash + Eq,
{
fn from(array: [K; N]) -> Self {
array.into_iter().collect()
}
}