Documentation ¶
Overview ¶
Package set defines a generic set type
Index ¶
- type Set
- func (s *Set[T]) Add(v T)
- func (s *Set[T]) Clear()
- func (s *Set[T]) Difference(other *Set[T]) *Set[T]
- func (s *Set[T]) Has(item 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 generic set.
func NewFromSlice ¶
func NewFromSlice[T comparable](slice []T) *Set[T]
NewFromSlice returns a new set from a slice.
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.