Documentation
¶
Index ¶
- type Set
- func (s *Set[T]) Add(val T)
- func (s *Set[T]) Clear()
- func (s *Set[T]) Diff(other *Set[T]) *Set[T]
- func (s *Set[T]) Equals(other *Set[T]) bool
- func (s *Set[T]) Has(val T) bool
- func (s *Set[T]) HasAll(val ...T) bool
- func (s *Set[T]) HasAny(val ...T) bool
- func (s *Set[T]) Intersect(other *Set[T]) *Set[T]
- func (s *Set[T]) IsEmpty() bool
- func (s *Set[T]) Len() int
- func (s *Set[T]) Range() iter.Seq[T]
- func (s *Set[T]) Remove(val T)
- func (s *Set[T]) Replace(vals []T)
- func (s *Set[T]) Slice() []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 generic set data structure that holds unique values of any comparable type T.
func New ¶
func New[T comparable](from ...[]T) *Set[T]
New creates a new Set. If an optional slice of values is provided, those values are added to the set.
func (*Set[T]) Add ¶
func (s *Set[T]) Add(val T)
Add adds the specified value to the set. If the value is already present, it has no effect.
func (*Set[T]) Equals ¶
Equals returns true if s and other contain the same elements, regardless of order.
func (*Set[T]) Intersect ¶
Intersect returns a new Set containing elements that are in both s and other.
func (*Set[T]) Remove ¶
func (s *Set[T]) Remove(val T)
Remove removes the specified value from the set. If the value is not present, it has no effect.
func (*Set[T]) Replace ¶
func (s *Set[T]) Replace(vals []T)
Replace replaces the contents of the set with the provided slice of values.
Click to show internal directories.
Click to hide internal directories.