Documentation
¶
Index ¶
- type HashSet
- func (self HashSet[TKey]) Add(key TKey)
- func (self HashSet[TKey]) AddAll(keys []TKey)
- func (self HashSet[TKey]) Clear()
- func (self HashSet[TKey]) Clone() HashSet[TKey]
- func (self HashSet[TKey]) Contains(key TKey) bool
- func (self HashSet[TKey]) ContainsAll(keys []TKey) bool
- func (self HashSet[TKey]) ContainsAny(keys []TKey) bool
- func (self HashSet[TKey]) DeepCloneBy(clone func(TKey) TKey) HashSet[TKey]
- func (self HashSet[TKey]) Difference(other HashSet[TKey]) HashSet[TKey]
- func (self HashSet[TKey]) Equal(other HashSet[TKey]) bool
- func (self HashSet[TKey]) ForEach(fn func(TKey))
- func (self HashSet[TKey]) Intersection(other HashSet[TKey]) HashSet[TKey]
- func (self HashSet[TKey]) IsEmpty() bool
- func (self HashSet[TKey]) Remove(key TKey)
- func (self HashSet[TKey]) RemoveBy(predicate func(TKey) bool)
- func (self HashSet[TKey]) Size() int
- func (self HashSet[TKey]) SubsetOf(other HashSet[TKey]) bool
- func (self HashSet[TKey]) SupersetOf(other HashSet[TKey]) bool
- func (self HashSet[TKey]) SymmetricDifference(other HashSet[TKey]) HashSet[TKey]
- func (self HashSet[TKey]) ToSlice() []TKey
- func (self HashSet[TKey]) Union(other HashSet[TKey]) HashSet[TKey]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HashSet ¶
type HashSet[TKey comparable] map[TKey]struct{}
func DeepClone ¶
func DeepClone[TKey interface { comparable clone.Cloneable[TKey] }]( set HashSet[TKey], ) HashSet[TKey]
DeepClone returns a copy of the set and clone each element.
func Map ¶
func Map[TKey, TNewKey comparable]( set HashSet[TKey], fn func(TKey) TNewKey, ) HashSet[TNewKey]
Map returns a new set containing all of the elements that are in this set and the given map.
func NewFromSlice ¶
func NewFromSlice[TKey comparable](slice []TKey) HashSet[TKey]
NewFromSlice creates a new hash set from a list of elements.
func NewHashSet ¶
func NewHashSet[TKey comparable]() HashSet[TKey]
NewHashSet returns a new empty hash set.
func (HashSet[TKey]) Add ¶
func (self HashSet[TKey]) Add(key TKey)
Add adds the given key to the set.
func (HashSet[TKey]) AddAll ¶
func (self HashSet[TKey]) AddAll(keys []TKey)
AddAll adds all the given keys to the set.
func (HashSet[TKey]) ContainsAll ¶
ContainsAll returns true if all of the given keys are in the set.
func (HashSet[TKey]) ContainsAny ¶
ContainsAny returns true if any of the given keys are in the set.
func (HashSet[TKey]) DeepCloneBy ¶
DeepCloneBy returns a copy of the set and clone each element use given clone func.
func (HashSet[TKey]) Difference ¶
Difference returns a new set containing all of the elements that are in this set but not in the other set.
func (HashSet[TKey]) Intersection ¶
Intersection returns a new set containing all of the elements that are in both sets.
func (HashSet[TKey]) Remove ¶
func (self HashSet[TKey]) Remove(key TKey)
Remove removes the given key from the set.
func (HashSet[TKey]) RemoveBy ¶
RemoveBy remove keys from the set if the given predicate returns true.
func (HashSet[TKey]) SupersetOf ¶
SupersetOf returns true if the given set is a superset of this set.
func (HashSet[TKey]) SymmetricDifference ¶
SymmetricDifference returns a new set containing all of the elements that are in this set or the other set but not in both.