Documentation
¶
Index ¶
- type HashSet
- func (hs *HashSet[T]) Add(v T)
- func (hs *HashSet[T]) AddAll(vs ...T)
- func (hs *HashSet[T]) AddCol(ac cog.Collection[T])
- func (hs *HashSet[T]) Clear()
- func (hs *HashSet[T]) Contains(v T) bool
- func (hs *HashSet[T]) ContainsAll(vs ...T) bool
- func (hs *HashSet[T]) ContainsAny(vs ...T) bool
- func (hs *HashSet[T]) ContainsCol(ac cog.Collection[T]) bool
- func (hs *HashSet[T]) ContainsIter(it cog.Iterator[T]) bool
- func (hs *HashSet[T]) Difference(a *HashSet[T]) *HashSet[T]
- func (hs *HashSet[T]) Each(f func(int, T) bool)
- func (hs *HashSet[T]) Intersection(a *HashSet[T]) *HashSet[T]
- func (hs *HashSet[T]) IsEmpty() bool
- func (hs *HashSet[T]) Len() int
- func (hs *HashSet[T]) MarshalJSON() ([]byte, error)
- func (hs *HashSet[T]) Remove(v T)
- func (hs *HashSet[T]) RemoveAll(vs ...T)
- func (hs *HashSet[T]) RemoveCol(ac cog.Collection[T])
- func (hs *HashSet[T]) RemoveFunc(f func(T) bool)
- func (hs *HashSet[T]) RemoveIter(it cog.Iterator[T])
- func (hs *HashSet[T]) RetainAll(vs ...T)
- func (hs *HashSet[T]) RetainCol(ac cog.Collection[T])
- func (hs *HashSet[T]) RetainFunc(f func(T) bool)
- func (hs *HashSet[T]) Seq() iter.Seq[T]
- func (hs *HashSet[T]) String() string
- func (hs *HashSet[T]) UnmarshalJSON(data []byte) error
- func (hs *HashSet[T]) Values() []T
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HashSet ¶
type HashSet[T comparable] struct { // contains filtered or unexported fields }
HashSet an unordered collection of unique values. The zero value for HashSet is an empty set ready to use. http://en.wikipedia.org/wiki/Set_(computer_science%29)
Example ¶
set := NewHashSet[int]()
set.Add(1) // 1
set.AddAll(2, 2, 3, 4, 5) // 3, 1, 2, 4, 5 (random order, duplicates ignored)
set.Remove(4) // 5, 3, 2, 1 (random order)
set.RemoveAll(2, 3) // 1, 5 (random order)
set.Contains(1) // true
set.ContainsAll(1, 5) // true
set.ContainsAll(1, 6) // false
_ = set.Values() // []int{5,1} (random order)
set.Clear() // empty
set.IsEmpty() // true
set.Len() // 0
func NewHashSet ¶
func NewHashSet[T comparable](vs ...T) *HashSet[T]
NewHashSet Create a new hash set
func (*HashSet[T]) AddAll ¶ added in v1.0.27
func (hs *HashSet[T]) AddAll(vs ...T)
AddAll AddAll all items of vs to the set
func (*HashSet[T]) AddCol ¶
func (hs *HashSet[T]) AddCol(ac cog.Collection[T])
AddCol adds all items of another collection
func (*HashSet[T]) ContainsAll ¶ added in v1.0.27
ContainsAll Test to see if the collection contains all items of vs
func (*HashSet[T]) ContainsAny ¶ added in v1.2.9
ContainsAll Test to see if the collection contains any item of vs
func (*HashSet[T]) ContainsCol ¶ added in v1.0.27
func (hs *HashSet[T]) ContainsCol(ac cog.Collection[T]) bool
ContainsCol Test to see if the collection contains all items of another collection
func (*HashSet[T]) ContainsIter ¶ added in v1.0.27
ContainsIter Test to see if the collection contains all items of iterator 'it'
func (*HashSet[T]) Difference ¶
Difference Find the difference btween two sets
func (*HashSet[T]) Intersection ¶
Intersection Find the intersection of two sets
func (*HashSet[T]) MarshalJSON ¶
MarshalJSON implements type json.Marshaler interface, so can be called in json.Marshal(hs)
func (*HashSet[T]) Remove ¶
func (hs *HashSet[T]) Remove(v T)
Remove remove all items with associated value v
func (*HashSet[T]) RemoveAll ¶ added in v1.0.27
func (hs *HashSet[T]) RemoveAll(vs ...T)
RemoveAll delete items of vs
func (*HashSet[T]) RemoveCol ¶
func (hs *HashSet[T]) RemoveCol(ac cog.Collection[T])
RemoveCol remove all of this collection's elements that are also contained in the specified collection
func (*HashSet[T]) RemoveFunc ¶
RemoveFunc remove all items that function f returns true
func (*HashSet[T]) RemoveIter ¶
RemoveIter remove all items in the iterator it
func (*HashSet[T]) RetainAll ¶ added in v1.0.27
func (hs *HashSet[T]) RetainAll(vs ...T)
RetainAll Retains only the elements in this collection that are contained in the argument array vs.
func (*HashSet[T]) RetainCol ¶
func (hs *HashSet[T]) RetainCol(ac cog.Collection[T])
RetainCol Retains only the elements in this collection that are contained in the specified collection.
func (*HashSet[T]) RetainFunc ¶
RetainFunc Retains all items that function f returns true
func (*HashSet[T]) UnmarshalJSON ¶
UnmarshalJSON implements type json.Unmarshaler interface, so can be called in json.Unmarshal(data, hs)