Documentation
¶
Index ¶
- type Option
- type Options
- type Set
- func (s Set[T]) Add(element T) bool
- func (s Set[T]) AddMany(elements ...T)
- func (s Set[T]) AddSeq(source iter.Seq[T])
- func (s Set[T]) AddSet(source Set[T])
- func (s Set[T]) AddSlice(source []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()
- 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]) 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]) Remove(element T) bool
- func (s Set[T]) RemoveMany(elements ...T)
- func (s Set[T]) RemoveSeq(source iter.Seq[T])
- func (s Set[T]) RemoveSet(source Set[T])
- func (s Set[T]) RemoveSlice(source []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 ¶ added in v1.0.3
func NewFromElements[T comparable](elements ...T) Set[T]
NewFromElements creates a new set with the given elements.
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 ¶
func (s Set[T]) AddMany(elements ...T)
AddMany adds the elements to the set.
func (Set[T]) AddSlice ¶
func (s Set[T]) AddSlice(source []T)
AddSlice adds the elements of the slice to the set.
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]) 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]) 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]) 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 ¶
func (s Set[T]) RemoveMany(elements ...T)
RemoveMany removes the elements from the set.
func (Set[T]) RemoveSlice ¶
func (s Set[T]) RemoveSlice(source []T)
RemoveSlice removes the elements of the slice from the set.
func (Set[T]) SymmetricDiff ¶
SymmetricDiff returns the symmetric difference between the set and another set.