Documentation
¶
Index ¶
- func AsSortedArray[K cmp.Ordered](s Set[K]) []K
- func Clone[K comparable, S ~map[K]struct{}](set S) S
- func Keys[K comparable, V any](m map[K]V, cmp maputils.CompareFunc[K]) []K
- type Set
- func (s Set[K]) Add(keys ...K) Set[K]
- func (s Set[K]) AddAll(set Set[K]) Set[K]
- func (s Set[K]) AsArray() []K
- func (s Set[K]) Clear() bool
- func (s Set[K]) Clone() Set[K]
- func (s Set[K]) Contains(keys ...K) bool
- func (s Set[K]) ContainsAll(items ...K) bool
- func (s Set[K]) ContainsAny(items ...K) bool
- func (s Set[K]) Delete(keys ...K) Set[K]
- func (s Set[K]) DeleteAll(set Set[K]) Set[K]
- func (s1 Set[K]) Difference(s2 Set[K]) Set[K]
- func (s Set[K]) Elements(yield func(e K) bool)
- func (s1 Set[K]) Equal(s2 Set[K]) bool
- func (s Set[K]) GetAny() (K, bool)
- func (s Set[K]) Has(keys ...K) bool
- func (s Set[K]) HasAll(keys ...K) bool
- func (s Set[K]) HasAny(keys ...K) bool
- func (s1 Set[K]) Intersection(s2 Set[K]) Set[K]
- func (s Set[K]) IsEmpty() bool
- func (s1 Set[K]) IsSubset(s2 Set[K]) bool
- func (s1 Set[K]) IsSuperset(s2 Set[K]) bool
- func (s Set[K]) Len() int
- func (s1 Set[K]) SymmetricDifference(s2 Set[K]) Set[K]
- func (s1 Set[K]) Union(s2 Set[K]) Set[K]
- func (s Set[K]) WithAdded(elems ...K) Set[K]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AsSortedArray ¶
AsSortedArray returns the contents as a sorted K slice.
This is a separate function and not a method because not all types supported by Generic are ordered and only those can be sorted.
func Clone ¶
func Clone[K comparable, S ~map[K]struct{}](set S) S
func Keys ¶
func Keys[K comparable, V any](m map[K]V, cmp maputils.CompareFunc[K]) []K
Types ¶
type Set ¶
type Set[K comparable] map[K]struct{}
func KeySet ¶
func KeySet[K comparable, V any](m map[K]V) Set[K]
func New ¶
func New[K comparable](keys ...K) Set[K]
func (Set[K]) ContainsAll ¶
func (Set[K]) ContainsAny ¶
func (Set[K]) Difference ¶
Difference returns a set of objects that are not in s2. For example: s1 = {a1, a2, a3} s2 = {a1, a2, a4, a5} s1.Difference(s2) = {a3} s2.Difference(s1) = {a4, a5}
func (Set[K]) Equal ¶
Equal returns true if and only if s1 is equal (as a set) to s2. Both sets contain the same elements.
func (Set[K]) Intersection ¶
Intersection returns a new set which includes the item in BOTH s1 and s2 For example: s1 = {a1, a2} s2 = {a2, a3} s1.Intersection(s2) = {a2}
func (Set[K]) IsSuperset ¶
IsSuperset returns true if and only if s1 is a superset of s2.
func (Set[K]) SymmetricDifference ¶
SymmetricDifference returns a set of elements which are in either of the sets, but not in their intersection. For example: s1 = {a1, a2, a3} s2 = {a1, a2, a4, a5} s1.SymmetricDifference(s2) = {a3, a4, a5} s2.SymmetricDifference(s1) = {a3, a4, a5}