blob: 80e2edde290e38fdd9f7d2681a205c621880400a (
plain) (
blame)
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
|
package ethutil
type Settable interface {
AsSet() UniqueSet
}
type UniqueSet map[interface{}]struct{}
func NewSet(v ...interface{}) UniqueSet {
set := make(UniqueSet)
for _, val := range v {
set.Insert(val)
}
return set
}
func (self UniqueSet) Insert(k interface{}) UniqueSet {
self[k] = struct{}{}
return self
}
func (self UniqueSet) Include(k interface{}) bool {
_, ok := self[k]
return ok
}
func Set(s Settable) UniqueSet {
return s.AsSet()
}
|