forked from External/ergo
Rename types.go -> stringset.go for consistency
This commit is contained in:
parent
e6ee9e50e0
commit
b4cb12a203
1 changed files with 1 additions and 0 deletions
|
|
@ -1,36 +0,0 @@
|
|||
// Copyright (c) 2020 Shivaram Lingamneni
|
||||
// released under the MIT license
|
||||
|
||||
package utils
|
||||
|
||||
type empty struct{}
|
||||
|
||||
type StringSet map[string]empty
|
||||
|
||||
func (s StringSet) Has(str string) bool {
|
||||
_, ok := s[str]
|
||||
return ok
|
||||
}
|
||||
|
||||
func (s StringSet) Add(str string) {
|
||||
s[str] = empty{}
|
||||
}
|
||||
|
||||
func (s StringSet) Remove(str string) {
|
||||
_, ok := s[str]
|
||||
if ok {
|
||||
delete(s, str)
|
||||
}
|
||||
}
|
||||
|
||||
func (s StringSet) Size() int {
|
||||
return len(s)
|
||||
}
|
||||
|
||||
func (s StringSet) Keys() (keys []string) {
|
||||
for key := range s {
|
||||
keys = append(keys, key)
|
||||
}
|
||||
|
||||
return keys
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue