blob: 7955edac071a16c16eec4c7edd747eb85d7d3ee3 (
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
33
34
35
36
|
package ethutil
type Settable interface {
AsSet() UniqueSet
}
type Stringable interface {
String() string
}
type UniqueSet map[string]struct{}
func NewSet(v ...Stringable) UniqueSet {
set := make(UniqueSet)
for _, val := range v {
set.Insert(val)
}
return set
}
func (self UniqueSet) Insert(k Stringable) UniqueSet {
self[k.String()] = struct{}{}
return self
}
func (self UniqueSet) Include(k Stringable) bool {
_, ok := self[k.String()]
return ok
}
func Set(s Settable) UniqueSet {
return s.AsSet()
}
|