Documentation ¶
Overview ¶
Package set implements a generic set container type.
Index ¶
- type Set
- func (s *Set[T]) Add(v T)
- func (s *Set[T]) All() iter.Seq[T]
- func (s *Set[T]) Clear()
- func (s *Set[T]) Contains(item T) bool
- func (s *Set[T]) Difference(other *Set[T]) *Set[T]
- func (s *Set[T]) Equal(other *Set[T]) bool
- func (s *Set[T]) Intersect(other *Set[T]) *Set[T]
- func (s *Set[T]) Remove(v T)
- func (s *Set[T]) Size() int
- func (s *Set[T]) String() string
- 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] struct { // contains filtered or unexported fields }
Set is a container for a set of values.
func NewFromSlice ¶
func NewFromSlice[T comparable](slice []T) *Set[T]
NewFromSlice returns a new set from a slice.
func (*Set[T]) All ¶
All returns on iterator over all elements of a set. Note that sets are unordered, so elements will be returned in no particular order.
func (*Set[T]) Difference ¶
Difference returns a new set which elements from current set, that does not exist in other set.
func (*Set[T]) Intersect ¶
Intersect returns a new set which contains elements found in both sets only.
func (*Set[T]) Remove ¶
func (s *Set[T]) Remove(v T)
Remove removes an element from a set. It does nothing when the element doesn't exist.
Click to show internal directories.
Click to hide internal directories.