import "github.com/ryantate13/hash-set"
- type Set
- func NewT comparable *Set[T]
- func Of[T comparable](els ...T) *Set[T]
- func (s *Set[T]) Add(els ...T) *Set[T]
- func (s *Set[T]) Difference(s2 *Set[T]) *Set[T]
- func (s *Set[T]) Empty() bool
- func (s *Set[T]) Filter(fn func(T) bool) *Set[T]
- func (s *Set[T]) Foreach(fn func(T)) *Set[T]
- func (s *Set[T]) Has(el T) bool
- func (s *Set[T]) Intersection(s2 *Set[T]) *Set[T]
- func (s *Set[T]) Len() int
- func (s *Set[T]) Remove(els ...T) *Set[T]
- func (s *Set[T]) Slice() []T
- func (s *Set[T]) Subset(s2 *Set[T]) bool
- func (s *Set[T]) Union(s2 *Set[T]) *Set[T]
Set is a collection type with unique elements
type Set[T comparable] struct {
// contains filtered or unexported fields
}
func New[T comparable]() *Set[T]
New instantiates an empty set
func Of[T comparable](els ...T) *Set[T]
Of instantiates a set with the given elements
func (s *Set[T]) Add(els ...T) *Set[T]
Add adds an element to the set, optionally supports chaining
func (s *Set[T]) Difference(s2 *Set[T]) *Set[T]
Difference returns the set of elements not in the other set
func (s *Set[T]) Empty() bool
Empty returns true if a set is empty
func (s *Set[T]) Filter(fn func(T) bool) *Set[T]
Filter returns the subset of a set that pass a given a filter func
func (s *Set[T]) Foreach(fn func(T)) *Set[T]
Foreach executes a callback function with every member of the set
func (s *Set[T]) Has(el T) bool
Has returns true if a given element is in a set
func (s *Set[T]) Intersection(s2 *Set[T]) *Set[T]
Intersection returns the set of elements common to both sets
func (s *Set[T]) Len() int
Len returns the number of elements in the set
func (s *Set[T]) Remove(els ...T) *Set[T]
Remove removes an element from the set, optionally supports chaining
func (s *Set[T]) Slice() []T
Slice returns the elements of the set as a slice
func (s *Set[T]) Subset(s2 *Set[T]) bool
Subset returns true if the set is a subset of another set
func (s *Set[T]) Union(s2 *Set[T]) *Set[T]
Union returns the combined elements of both sets
Generated by gomarkdoc