Documentation ¶
Overview ¶
Package set implements support for a generic unordered Set. A Set is a Collection that wraps an underlying hash map and provides convenience methods and syntatic sugar on top of it.
Set elements are unique and unordered by default. However Sets share some methods with other collections and implement the Collection interface.
Index ¶
- type Set
- func (s *Set[T]) Add(v T)
- func (s *Set[T]) Apply(f func(T) T) *Set[T]
- func (s *Set[T]) Clone() *Set[T]
- func (s *Set[T]) Contains(v T) bool
- func (s *Set[T]) ContainsFunc(f func(T) bool) bool
- func (s *Set[T]) Count(f func(T) bool) int
- func (s *Set[T]) Diff(set *Set[T]) *Set[T]
- func (s *Set[T]) Equals(s2 *Set[T]) bool
- func (s *Set[T]) Filter(f func(T) bool) *Set[T]
- func (s *Set[T]) FilterNot(f func(T) bool) *Set[T]
- func (s *Set[T]) ForAll(f func(T) bool) bool
- func (s *Set[T]) Intersection(s2 *Set[T]) *Set[T]
- func (s *Set[T]) IsEmpty() bool
- func (s *Set[T]) Length() int
- func (s *Set[T]) New(s2 ...[]T) collection.Collection[T]
- func (s *Set[T]) NonEmpty() bool
- func (s *Set[T]) Partition(f func(T) bool) (*Set[T], *Set[T])
- func (s *Set[T]) Random() T
- func (s *Set[T]) Remove(v T)
- func (s *Set[T]) String() string
- func (s *Set[T]) ToSlice() []T
- func (s *Set[T]) Union(s2 *Set[T]) *Set[T]
- func (s *Set[T]) Values() iter.Seq[T]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Set ¶
type Set[T comparable] struct { // contains filtered or unexported fields }
func NewSet ¶
func NewSet[T comparable](s ...[]T) *Set[T]
func (*Set[T]) ContainsFunc ¶
ContainsFunc returns true if the set contains a value that satisfies the predicate.
func (*Set[T]) Diff ¶
Difference returns a new set containing the difference of the current set and the passed in set.
func (*Set[T]) Intersection ¶
Intersection returns a new set containing the intersection of the current set and the passed in set.
func (*Set[T]) New ¶
func (s *Set[T]) New(s2 ...[]T) collection.Collection[T]
Click to show internal directories.
Click to hide internal directories.