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

31 lines
411 B
Go
Raw Normal View History

2021-06-13 14:59:50 +00:00
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)
2021-07-02 09:00:18 +00:00
for k := range s {
2021-06-13 14:59:50 +00:00
keys = append(keys, k)
}
return keys
}