mirror of
https://github.com/anchore/grype
synced 2024-11-10 14:44:12 +00:00
30 lines
440 B
Go
30 lines
440 B
Go
package internal
|
|
|
|
type StringSet map[string]struct{}
|
|
|
|
func NewStringSet() StringSet {
|
|
return make(StringSet)
|
|
}
|
|
|
|
func (s StringSet) Add(i string) {
|
|
s[i] = struct{}{}
|
|
}
|
|
|
|
func (s StringSet) Remove(i string) {
|
|
delete(s, i)
|
|
}
|
|
|
|
func (s StringSet) Contains(i string) bool {
|
|
_, ok := s[i]
|
|
return ok
|
|
}
|
|
|
|
func (s StringSet) ToSlice() []string {
|
|
ret := make([]string, len(s))
|
|
idx := 0
|
|
for v := range s {
|
|
ret[idx] = v
|
|
idx++
|
|
}
|
|
return ret
|
|
}
|