1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
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)
}
}