use crate::maps::Map;
use crate::sets::Set;
use crate::MultiMap;
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
use std::hash::Hash;
pub struct MultiMapBuilder {}
impl MultiMapBuilder {
pub fn hash_keys<K, S>() -> MultiMapBuilderWithKeys<HashMap<K, S>>
where
K: Hash + Eq,
{
Self::with_map_type()
}
pub fn sorted_keys<K, S>() -> MultiMapBuilderWithKeys<BTreeMap<K, S>>
where
K: Ord,
{
Self::with_map_type()
}
pub fn with_map_type<M>() -> MultiMapBuilderWithKeys<M>
where
M: Map,
{
MultiMapBuilderWithKeys {
_m: std::marker::PhantomData,
}
}
}
pub struct MultiMapBuilderWithKeys<M>
where
M: Map,
{
_m: std::marker::PhantomData<M>,
}
impl<M> MultiMapBuilderWithKeys<M>
where
M: Map,
{
pub fn hash_values<V>(self) -> MultiMapBuilderWithKeysAndVals<M>
where
M: Map<Val = HashSet<V>>,
V: Hash + Eq,
{
self.with_set_type()
}
pub fn sorted_values<V>(self) -> MultiMapBuilderWithKeysAndVals<M>
where
M: Map<Val = BTreeSet<V>>,
V: Ord,
{
self.with_set_type()
}
pub fn with_set_type(self) -> MultiMapBuilderWithKeysAndVals<M>
where
M: Map,
M::Val: Set,
{
MultiMapBuilderWithKeysAndVals {
_m: std::marker::PhantomData,
}
}
}
pub struct MultiMapBuilderWithKeysAndVals<M> {
_m: std::marker::PhantomData<M>,
}
impl<M> MultiMapBuilderWithKeysAndVals<M>
where
M: Default,
{
pub fn build(self) -> MultiMap<M> {
Default::default()
}
}