Documentation
¶
Overview ¶
Package hashset implements the set data structure based on hash table. It is safe for concurrent use.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Equal ¶
func Equal[K comparable](s1, s2 *HashSet[K]) bool
Equal reports whether two sets contain the same elements
Types ¶
type HashSet ¶
type HashSet[K comparable] struct { // contains filtered or unexported fields }
HashSet holds a set of unique elements
func Collect ¶
func Collect[K comparable](seq iter.Seq[K]) *HashSet[K]
Collect creates a new set from an iterator
func Difference ¶
func Difference[K comparable](s1, s2 *HashSet[K]) *HashSet[K]
Difference returns a new set that contains elements that are in the first set but not in the second set
func Intersection ¶
func Intersection[K comparable](s1, s2 *HashSet[K]) *HashSet[K]
Intersection returns a new set that contains common elements from two sets
func Union ¶
func Union[K comparable](s1, s2 *HashSet[K]) *HashSet[K]
Union returns a new set that contains all elements from two sets
func (*HashSet[K]) Add ¶
func (s *HashSet[K]) Add(key K)
Add adds an element to the set If an element already exists in the set, it is ignored.
Click to show internal directories.
Click to hide internal directories.