use std::collections::HashSet;
use std::hash::{BuildHasher, Hash};
pub trait ItemSet<I>
where
I: Copy,
{
fn is_empty(&self) -> bool {
self.len() == 0
}
fn len(&self) -> usize;
fn clear(&mut self);
fn insert(&mut self, u: I) -> bool;
fn remove(&mut self, u: I) -> bool;
fn contains(&self, u: I) -> bool;
}
impl<'a, N, S> ItemSet<N> for &'a mut S
where
S: ItemSet<N>,
N: Copy,
{
fn is_empty(&self) -> bool {
(**self).is_empty()
}
fn len(&self) -> usize {
(**self).len()
}
fn clear(&mut self) {
(**self).clear()
}
fn insert(&mut self, u: N) -> bool {
(**self).insert(u)
}
fn remove(&mut self, u: N) -> bool {
(**self).remove(u)
}
fn contains(&self, u: N) -> bool {
(**self).contains(u)
}
}
impl<N, B> ItemSet<N> for HashSet<N, B>
where
N: Copy + Eq + Hash,
B: BuildHasher,
{
fn is_empty(&self) -> bool {
HashSet::is_empty(self)
}
fn len(&self) -> usize {
HashSet::len(self)
}
fn clear(&mut self) {
HashSet::clear(self)
}
fn insert(&mut self, u: N) -> bool {
HashSet::insert(self, u)
}
fn remove(&mut self, u: N) -> bool {
HashSet::remove(self, &u)
}
fn contains(&self, u: N) -> bool {
HashSet::contains(self, &u)
}
}