auto-deploy-service/pkg/set/set.go

31 lines
411 B
Go

package set
type Set map[interface{}]struct{}
func NewSet() Set {
return make(map[interface{}]struct{})
}
func (s Set) Add(i interface{}) {
s[i] = struct{}{}
}
func (s Set) Has(i interface{}) bool {
_, ok := s[i]
return ok
}
func (s Set) Size() int {
return len(s)
}
func (s Set) Keys() []interface{} {
keys := make([]interface{}, 0)
for k := range s {
keys = append(keys, k)
}
return keys
}