Documentation ¶
Index ¶
- type Set
- func (s Set) Add(items ...string)
- func (s *Set) Clear()
- func (s Set) Copy() Set
- func (s Set) GetOne() string
- func (s Set) GetOne2() (string, bool)
- func (s Set) Has(items ...string) bool
- func (s Set) HasAny(items ...string) bool
- func (s Set) HasWithPrefix(items ...string) bool
- func (s Set) IsEqual(t Set) bool
- func (s Set) IsSubset(t Set) bool
- func (s Set) IsSuperset(t Set) bool
- func (s Set) Merge(sets ...Set)
- func (s Set) Pop() string
- func (s Set) Pop2() (string, bool)
- func (s Set) Remove(items ...string)
- func (s Set) Shrink(targetLen int)
- func (s Set) ShrinkSorted(targetLen int)
- func (s Set) Slice() []string
- func (s Set) SliceSorted() []string
- func (s Set) String() string
- func (s Set) Subtract(sets ...Set)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Set ¶
type Set map[string]struct{}
func Difference ¶
Difference returns a new set which contains items which are in the first set but not in the others.
func Intersection ¶
Intersection returns a new set which contains items that only exist in all given sets.
func NewWithSize ¶
NewWithSize creates a new Set and gives make map a size hint.
func SymmetricDifference ¶
SymmetricDifference returns a new set which s is the difference of items which are in one of either, but not in both.
func Union ¶
Union is the merger of multiple sets. It returns a new set with all the elements present in all the sets that are passed.
func (Set) Add ¶
Add includes the specified items (one or more) to the Set. The underlying Set s is modified. If passed nothing it silently returns.
func (Set) GetOne2 ¶ added in v0.18.0
GetOne2 returns an item from the set. The second value is a bool that is true if an item exists in the set, or false if the set is empty.
func (Set) Has ¶
Has looks for the existence of items passed. It returns false if nothing is passed. For multiple items it returns true only if all of the items exist.
func (Set) HasAny ¶
HasAny looks for the existence of any of the items passed. It returns false if nothing is passed. For multiple items it returns true if any of the items exist.
func (Set) HasWithPrefix ¶ added in v0.31.0
HasWithPrefix checks if at least one element of the set is the prefix of any of the passed items. It returns false if nothing is passed.
func (Set) IsSuperset ¶
IsSuperset tests whether t is a superset of s.
func (Set) Merge ¶
Merge is like Union, however it modifies the current Set it's applied on with the given t Set.
func (Set) Pop ¶
Pop deletes and returns an item from the Set. The underlying Set s is modified. If Set is empty, the zero value is returned.
func (Set) Pop2 ¶
Pop2 tries to delete and return an item from the Set. The underlying Set s is modified. The second value is a bool that is true if the item existed in the set, and false if not. If Set is empty, the zero value and false are returned.
func (Set) Remove ¶
Remove deletes the specified items from the Set. The underlying Set s is modified. If passed nothing it silently returns.
func (Set) ShrinkSorted ¶ added in v0.16.0
remove items alphabetically until len(s) <= targetLen
func (Set) SliceSorted ¶ added in v0.15.0
List returns a sorted slice of all items (a to z).