mirror of
https://github.com/status-im/op-geth.git
synced 2025-01-10 22:56:08 +00:00
33 lines
467 B
Go
33 lines
467 B
Go
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()
|
|
}
|