Documentation ¶
Overview ¶
Package stringset is an exceedingly simple 'set' implementation for strings.
It's not threadsafe, but can be used in place of a simple `map[string]struct{}`
Index ¶
- type Set
- func (s Set) Add(value string) bool
- func (s Set) Del(value string) bool
- func (s Set) Difference(other Set) Set
- func (s Set) Dup() Set
- func (s Set) Has(value string) bool
- func (s Set) Intersect(other Set) Set
- func (s Set) Iter(cb func(string) bool)
- func (s Set) Len() int
- func (s Set) Peek() (string, bool)
- func (s Set) Pop() (string, bool)
- func (s Set) ToSlice() []string
- func (s Set) Union(other Set) Set
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Set ¶
type Set map[string]struct{}
Set is the base type. make(Set) can be used too.
func NewFromSlice ¶
NewFromSlice returns a new string Set implementation, initialized with the values in the provided slice.
func (Set) Add ¶
Add ensures that Set contains value, and returns true if it was added (i.e. it returns false if the Set already contained the value).
func (Set) Del ¶
Del removes value from the set, and returns true if it was deleted (i.e. it returns false if the Set did not already contain the value).
func (Set) Difference ¶
Difference returns a new Set which is this set with all elements from other removed (i.e. `self - other`).
`other` must have the same underlying type as the current set, or this will panic.
func (Set) Intersect ¶
Intersect returns a new Set which is the intersection of this set with the other set.
`other` must have the same underlying type as the current set, or this will panic.
func (Set) Iter ¶
Iter calls `cb` for each item in the set. If `cb` returns false, the iteration stops.
func (Set) Peek ¶
Peek returns an arbitrary element from the set. If the set was empty, this returns ("", false).
func (Set) Pop ¶
Peek removes and returns an arbitrary element from the set. If the set was empty, this returns ("", false).