github.com/pankona/gometalinter@v2.0.11+incompatible/stringset.go (about) 1 package main 2 3 type stringSet struct { 4 items map[string]struct{} 5 } 6 7 func newStringSet(items ...string) *stringSet { 8 setItems := make(map[string]struct{}, len(items)) 9 for _, item := range items { 10 setItems[item] = struct{}{} 11 } 12 return &stringSet{items: setItems} 13 } 14 15 func (s *stringSet) add(item string) { 16 s.items[item] = struct{}{} 17 } 18 19 func (s *stringSet) asSlice() []string { 20 items := []string{} 21 for item := range s.items { 22 items = append(items, item) 23 } 24 return items 25 } 26 27 func (s *stringSet) size() int { 28 return len(s.items) 29 }