Documentation
¶
Index ¶
- type ConcurrencySafeSet
- func (s *ConcurrencySafeSet[T]) Add(ss ...T) Set[T]
- func (s *ConcurrencySafeSet[T]) Copy() Set[T]
- func (s *ConcurrencySafeSet[T]) Equals(comp Set[T]) bool
- func (s *ConcurrencySafeSet[T]) Has(e T) bool
- func (s *ConcurrencySafeSet[T]) Iter() iter.Seq[T]
- func (s *ConcurrencySafeSet[T]) Join(ss Set[T]) Set[T]
- func (s *ConcurrencySafeSet[T]) Remove(ss ...T) Set[T]
- func (s *ConcurrencySafeSet[T]) Size() int
- func (s *ConcurrencySafeSet[T]) Slice() []T
- type Set
- type SimpleSet
- func (s SimpleSet[T]) Add(ss ...T) Set[T]
- func (s SimpleSet[T]) Copy() Set[T]
- func (s SimpleSet[T]) Equals(comp Set[T]) bool
- func (s SimpleSet[T]) Has(e T) bool
- func (s SimpleSet[T]) Iter() iter.Seq[T]
- func (s SimpleSet[T]) Join(ss Set[T]) Set[T]
- func (s SimpleSet[T]) Remove(ss ...T) Set[T]
- func (s SimpleSet[T]) Size() int
- func (s SimpleSet[T]) Slice() []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConcurrencySafeSet ¶ added in v1.3.6
type ConcurrencySafeSet[T comparable] struct { sync.RWMutex // contains filtered or unexported fields }
ConcurrencySafeSet represents a set of unique elements.
func NewConcurrencySafe ¶ added in v1.3.6
func NewConcurrencySafe[T comparable](ss ...T) *ConcurrencySafeSet[T]
NewConcurrencySafe returns a new concurrency-safe set.
func (*ConcurrencySafeSet[T]) Add ¶ added in v1.3.6
func (s *ConcurrencySafeSet[T]) Add(ss ...T) Set[T]
Add adds a list of elements to a set.
func (*ConcurrencySafeSet[T]) Copy ¶ added in v1.3.6
func (s *ConcurrencySafeSet[T]) Copy() Set[T]
Copy returns a copy of a set.
func (*ConcurrencySafeSet[T]) Equals ¶ added in v1.4.22
func (s *ConcurrencySafeSet[T]) Equals(comp Set[T]) bool
Equals returns true if a given set is equal (has the same elements).
func (*ConcurrencySafeSet[T]) Has ¶ added in v1.3.6
func (s *ConcurrencySafeSet[T]) Has(e T) bool
Has returns true if an element is in a set.
func (*ConcurrencySafeSet[T]) Iter ¶ added in v1.4.87
func (s *ConcurrencySafeSet[T]) Iter() iter.Seq[T]
Iter returns an iterator for a copy of the set. Note that elements are iterated through in no particular order.
func (*ConcurrencySafeSet[T]) Join ¶ added in v1.3.6
func (s *ConcurrencySafeSet[T]) Join(ss Set[T]) Set[T]
Join joins two sets.
func (*ConcurrencySafeSet[T]) Remove ¶ added in v1.3.6
func (s *ConcurrencySafeSet[T]) Remove(ss ...T) Set[T]
Remove removes a list of elements from a set.
func (*ConcurrencySafeSet[T]) Size ¶ added in v1.3.7
func (s *ConcurrencySafeSet[T]) Size() int
Size returns the number of elements in the set.
func (*ConcurrencySafeSet[T]) Slice ¶ added in v1.3.6
func (s *ConcurrencySafeSet[T]) Slice() []T
Slice returns the set as a slice.
type Set ¶
type Set[T comparable] interface { Has(T) bool Add(...T) Set[T] Remove(...T) Set[T] Join(Set[T]) Set[T] Iter() iter.Seq[T] Copy() Set[T] Slice() []T Size() int Equals(Set[T]) bool }
Set represents a set of unique elements.
type SimpleSet ¶ added in v1.3.6
type SimpleSet[T comparable] map[T]struct{}
SimpleSet represents a set of unique elements.
func (SimpleSet[T]) Equals ¶ added in v1.4.22
Equals returns true if a given set is equal (has the same elements).
func (SimpleSet[T]) Iter ¶ added in v1.4.87
Iter returns an iterator for the set. Note that elements are iterated through in no particular order.