Documentation
¶
Index ¶
- type Option
- type Options
- type Set
- func New[T comparable](options ...Option) Set[T]
- func NewFromElements[T comparable](elements ...T) Set[T]
- func NewFromMapKeys[T comparable, V any](m map[T]V) Set[T]
- func NewFromMapValues[T comparable, V comparable](m map[T]V) Set[V]
- func NewFromSeq[T comparable](source iter.Seq[T]) Set[T]
- func NewFromSet[T comparable](source Set[T]) Set[T]
- func NewFromSlice[T comparable](source []T) Set[T]
- func (s Set[T]) Add(element T) bool
- func (s Set[T]) AddMany(elements ...T) Set[T]
- func (s Set[T]) AddSeq(source iter.Seq[T]) Set[T]
- func (s Set[T]) AddSet(source Set[T]) Set[T]
- func (s Set[T]) AddSlice(source []T) Set[T]
- func (s Set[T]) All(f func(T) bool) bool
- func (s Set[T]) Any(f func(T) bool) bool
- func (s Set[T]) Clear() Set[T]
- func (s Set[T]) Clone() Set[T]
- func (s Set[T]) Contains(elements ...T) bool
- func (s Set[T]) ContainsAny(elements ...T) bool
- func (s Set[T]) ContainsAnyFromSeq(source iter.Seq[T]) bool
- func (s Set[T]) ContainsAnyFromSet(other Set[T]) bool
- func (s Set[T]) ContainsAnyFromSlice(source []T) bool
- func (s Set[T]) ContainsSeq(source iter.Seq[T]) bool
- func (s Set[T]) ContainsSet(other Set[T]) bool
- func (s Set[T]) ContainsSlice(source []T) bool
- func (s Set[T]) Count(f func(T) bool) int
- func (s Set[T]) Diff(other Set[T]) Set[T]
- func (s Set[T]) Equal(other Set[T]) bool
- func (s Set[T]) Filter(f func(T) bool) Set[T]
- func (s Set[T]) ForEach(f func(T))
- func (s Set[T]) IsEmpty() bool
- func (s Set[T]) IsProperSubsetOf(other Set[T]) bool
- func (s Set[T]) IsProperSupersetOf(other Set[T]) bool
- func (s Set[T]) IsSubsetOf(other Set[T]) bool
- func (s Set[T]) IsSupersetOf(other Set[T]) bool
- func (s Set[T]) Len() int
- func (s Set[T]) None(f func(T) bool) bool
- func (s Set[T]) Remove(element T) bool
- func (s Set[T]) RemoveMany(elements ...T) Set[T]
- func (s Set[T]) RemoveSeq(source iter.Seq[T]) Set[T]
- func (s Set[T]) RemoveSet(source Set[T]) Set[T]
- func (s Set[T]) RemoveSlice(source []T) Set[T]
- func (s Set[T]) SymmetricDiff(other Set[T]) Set[T]
- func (s Set[T]) ToSeq() iter.Seq[T]
- func (s Set[T]) ToSlice() []T
- func (s Set[T]) Union(other Set[T]) Set[T]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Set ¶
type Set[T comparable] map[T]struct{}
Set is a set of elements.
func New ¶
func New[T comparable](options ...Option) Set[T]
New creates a new set with the given options.
func NewFromElements ¶
func NewFromElements[T comparable](elements ...T) Set[T]
NewFromElements creates a new set with the given elements.
func NewFromMapKeys ¶ added in v1.0.2
func NewFromMapKeys[T comparable, V any](m map[T]V) Set[T]
NewFromMapKeys creates a new set with the keys of the map.
func NewFromMapValues ¶ added in v1.0.2
func NewFromMapValues[T comparable, V comparable](m map[T]V) Set[V]
NewFromMapValues creates a new set with the values of the map.
func NewFromSeq ¶
func NewFromSeq[T comparable](source iter.Seq[T]) Set[T]
NewFromSeq creates a new set with the elements of the sequence.
func NewFromSet ¶
func NewFromSet[T comparable](source Set[T]) Set[T]
NewFromSet creates a new set with the elements of the other set.
func NewFromSlice ¶
func NewFromSlice[T comparable](source []T) Set[T]
NewFromSlice creates a new set with the elements of the slice.
func (Set[T]) Add ¶
Add adds the element to the set. Returns true if the element was added. Returns false if the element was already in the set.
func (Set[T]) AddMany ¶
AddMany adds the elements to the set. Modifies the set in place. Returns the set itself.
func (Set[T]) AddSeq ¶
AddSeq adds the elements of the sequence to the set. Modifies the set in place. Returns the set itself.
func (Set[T]) AddSet ¶
AddSet adds the elements of the other set to the set. Modifies the set in place. Returns the set itself.
func (Set[T]) AddSlice ¶
AddSlice adds the elements of the slice to the set. Modifies the set in place. Returns the set itself.
func (Set[T]) All ¶
All returns true if all elements in set satisfy the predicate f. If set is empty, All returns true.
func (Set[T]) Any ¶
Any returns true if any element in set satisfies the predicate, false otherwise. If set is empty, Any returns false.
func (Set[T]) Clear ¶
Clear removes all elements from the set. Modifies the set in place. Returns the set itself.
func (Set[T]) ContainsAny ¶
ContainsAny returns true if the set contains any of the elements.
func (Set[T]) ContainsAnyFromSeq ¶
ContainsAnyFromSeq returns true if the set contains any of the elements of the sequence.
func (Set[T]) ContainsAnyFromSet ¶
ContainsAnyFromSet returns true if the set contains any of the elements of the other set.
func (Set[T]) ContainsAnyFromSlice ¶
ContainsAnyFromSlice returns true if the set contains any of the elements of the slice.
func (Set[T]) ContainsSeq ¶
ContainsSeq returns true if the set contains all elements of the sequence.
func (Set[T]) ContainsSet ¶
ContainsSet returns true if the set contains all elements of the other set.
func (Set[T]) ContainsSlice ¶
ContainsSlice returns true if the set contains all elements of the slice.
func (Set[T]) Filter ¶
Filter returns a new set containing only the elements that satisfy the predicate f.
func (Set[T]) ForEach ¶ added in v1.0.2
func (s Set[T]) ForEach(f func(T))
ForEach executes the function f for each element in the set.
func (Set[T]) IsProperSubsetOf ¶
IsProperSubsetOf returns true if the set is a proper subset of the other set.
func (Set[T]) IsProperSupersetOf ¶
IsProperSupersetOf returns true if the set is a proper superset of the other set.
func (Set[T]) IsSubsetOf ¶
IsSubsetOf returns true if the set is a subset of the other set.
func (Set[T]) IsSupersetOf ¶
IsSupersetOf returns true if the set is a superset of the other set.
func (Set[T]) None ¶ added in v1.0.2
None returns true if no elements in set satisfy the predicate f.
func (Set[T]) Remove ¶
Remove removes the element from the set. Returns true if the element was removed. Returns false if the element was not in the set.
func (Set[T]) RemoveMany ¶
RemoveMany removes the elements from the set. Modifies the set in place. Returns the set itself.
func (Set[T]) RemoveSeq ¶
RemoveSeq removes the elements of the sequence from the set. Modifies the set in place. Returns the set itself.
func (Set[T]) RemoveSet ¶
RemoveSet removes the elements of the other set from the set. Modifies the set in place. Returns the set itself.
func (Set[T]) RemoveSlice ¶
RemoveSlice removes the elements of the slice from the set. Modifies the set in place. Returns the set itself.
func (Set[T]) SymmetricDiff ¶
SymmetricDiff returns the symmetric difference between the set and another set.