Documentation ¶
Index ¶
- type FrozenStringSet
- func (k FrozenStringSet) AsSlice() []string
- func (k FrozenStringSet) AsSortedSlice(less func(i, j string) bool) []string
- func (k FrozenStringSet) Cardinality() int
- func (k FrozenStringSet) Contains(elem string) bool
- func (k FrozenStringSet) Difference(other FrozenStringSet) FrozenStringSet
- func (k FrozenStringSet) ElementsString(sep string) string
- func (k FrozenStringSet) Intersect(other FrozenStringSet) FrozenStringSet
- func (k FrozenStringSet) IsEmpty() bool
- func (k FrozenStringSet) Unfreeze() StringSet
- func (k FrozenStringSet) Union(other FrozenStringSet) FrozenStringSet
- type StringSet
- func (k *StringSet) Add(i string) bool
- func (k *StringSet) AddAll(is ...string) bool
- func (k *StringSet) AddMatching(matchFunc func(string) bool, elems ...string) bool
- func (k StringSet) AsSlice() []string
- func (k StringSet) AsSortedSlice(less func(i, j string) bool) []string
- func (k StringSet) Cardinality() int
- func (k *StringSet) Clear()
- func (k StringSet) Clone() StringSet
- func (k StringSet) Contains(i string) bool
- func (k StringSet) Difference(other StringSet) StringSet
- func (k StringSet) ElementsString(sep string) string
- func (k StringSet) Equal(other StringSet) bool
- func (k StringSet) Freeze() FrozenStringSet
- func (k StringSet) GetArbitraryElem() (arbitraryElem string)
- func (k StringSet) Intersect(other StringSet) StringSet
- func (k StringSet) Intersects(other StringSet) bool
- func (k StringSet) IsEmpty() bool
- func (k *StringSet) Remove(i string) bool
- func (k *StringSet) RemoveAll(is ...string) bool
- func (k *StringSet) RemoveMatching(pred func(string) bool) bool
- func (k StringSet) Union(other StringSet) StringSet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FrozenStringSet ¶
type FrozenStringSet struct {
// contains filtered or unexported fields
}
A FrozenStringSet is a frozen set of string elements, which cannot be modified after creation. This allows users to use it as if it were a "const" data structure, and also makes it slightly more optimal since we don't have to lock accesses to it.
func NewFrozenStringSet ¶
func NewFrozenStringSet(elements ...string) FrozenStringSet
NewFrozenStringSet returns a new frozen set with the provided elements.
func NewFrozenStringSetFromMap ¶
func NewFrozenStringSetFromMap(m map[string]struct{}) FrozenStringSet
NewFrozenStringSetFromMap returns a new frozen set from the set-style map.
func (FrozenStringSet) AsSlice ¶
func (k FrozenStringSet) AsSlice() []string
AsSlice returns the elements of the set. The order is unspecified.
func (FrozenStringSet) AsSortedSlice ¶
func (k FrozenStringSet) AsSortedSlice(less func(i, j string) bool) []string
AsSortedSlice returns the elements of the set as a sorted slice.
func (FrozenStringSet) Cardinality ¶
func (k FrozenStringSet) Cardinality() int
Cardinality returns the cardinality of the set.
func (FrozenStringSet) Contains ¶
func (k FrozenStringSet) Contains(elem string) bool
Contains returns whether the set contains the element.
func (FrozenStringSet) Difference ¶
func (k FrozenStringSet) Difference(other FrozenStringSet) FrozenStringSet
Difference returns a frozen set that represents the set difference between this and other.
func (FrozenStringSet) ElementsString ¶
func (k FrozenStringSet) ElementsString(sep string) string
ElementsString returns a string representation of all elements, with individual element strings separated by `sep`. The string representation of an individual element is obtained via `fmt.Fprint`.
func (FrozenStringSet) Intersect ¶
func (k FrozenStringSet) Intersect(other FrozenStringSet) FrozenStringSet
Intersect returns a frozen set that represents the intersection between this and other.
func (FrozenStringSet) IsEmpty ¶
func (k FrozenStringSet) IsEmpty() bool
IsEmpty returns whether the underlying set is empty (includes uninitialized).
func (FrozenStringSet) Unfreeze ¶
func (k FrozenStringSet) Unfreeze() StringSet
Unfreeze returns a mutable set with the same contents as this frozen set. This set will not be affected by any subsequent modifications to the returned set.
func (FrozenStringSet) Union ¶
func (k FrozenStringSet) Union(other FrozenStringSet) FrozenStringSet
Union returns a frozen set that represents the union between this and other.
type StringSet ¶
type StringSet map[string]struct{}
StringSet will get translated to generic sets.
func NewStringSet ¶
NewStringSet returns a new thread unsafe set with the given key type.
func (*StringSet) AddAll ¶
AddAll adds all elements of type string. The return value is true if any new element was added.
func (*StringSet) AddMatching ¶
AddMatching is a utility function that adds all the elements that match the given function to the set.
func (StringSet) AsSlice ¶
AsSlice returns a slice of the elements in the set. The order is unspecified.
func (StringSet) AsSortedSlice ¶
AsSortedSlice returns a slice of the elements in the set, sorted using the passed less function.
func (StringSet) Cardinality ¶
Cardinality returns the number of elements in the set.
func (StringSet) Difference ¶
Difference returns a new set with all elements of k not in other.
func (StringSet) ElementsString ¶
ElementsString returns a string representation of all elements, with individual element strings separated by `sep`. The string representation of an individual element is obtained via `fmt.Fprint`.
func (StringSet) Freeze ¶
func (k StringSet) Freeze() FrozenStringSet
Freeze returns a new, frozen version of the set.
func (StringSet) GetArbitraryElem ¶
GetArbitraryElem returns an arbitrary element from the set. This can be useful if, for example, you know the set has exactly one element, and you want to pull it out. If the set is empty, the zero value is returned.
func (StringSet) Intersect ¶
Intersect returns a new set with the intersection of the members of both sets.
func (StringSet) Intersects ¶
Intersects returns whether the set has a non-empty intersection with the other set.
func (StringSet) IsEmpty ¶
IsEmpty returns whether the underlying set is empty (includes uninitialized).
func (*StringSet) RemoveMatching ¶
RemoveMatching removes all elements that match a given predicate.