sets

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HashSet

type HashSet[TKey comparable] struct {
	// contains filtered or unexported fields
}

func FromMapKey added in v0.3.0

func FromMapKey[TKey comparable, TValue any, M ~map[TKey]TValue](m M) *HashSet[TKey]

func Map

func Map[TKey, TNewKey comparable](
	set *HashSet[TKey],
	fn func(TKey) TNewKey,
) *HashSet[TNewKey]

Map maps each element in current HashSet to a new HashSet.

func NewHashSet

func NewHashSet[TKey comparable](elements ...TKey) *HashSet[TKey]

NewHashSet returns a new empty hash set.

func (*HashSet[TKey]) Add

func (self *HashSet[TKey]) Add(keys ...TKey)

Add adds the given keys to the set.

func (*HashSet[TKey]) AddAll

func (self *HashSet[TKey]) AddAll(other *HashSet[TKey])

AddAll adds all elements in other HashSet

func (*HashSet[TKey]) Clear

func (self *HashSet[TKey]) Clear()

Clear removes all keys from the set.

func (*HashSet[TKey]) Clone

func (self *HashSet[TKey]) Clone() *HashSet[TKey]

Clone returns a copy of the set.

func (*HashSet[TKey]) Contains

func (self *HashSet[TKey]) Contains(key TKey) bool

Contains returns true if the given key is in the set.

func (*HashSet[TKey]) ContainsAll

func (self *HashSet[TKey]) ContainsAll(keys []TKey) bool

ContainsAll returns true if all the given keys are in the set.

func (*HashSet[TKey]) ContainsAny

func (self *HashSet[TKey]) ContainsAny(keys []TKey) bool

ContainsAny returns true if any of the given keys are in the set.

func (*HashSet[TKey]) DeepCloneBy

func (self *HashSet[TKey]) DeepCloneBy(clone func(TKey) TKey) *HashSet[TKey]

DeepCloneBy returns a copy of the set and clone each element use given clone func.

func (*HashSet[TKey]) Difference

func (self *HashSet[TKey]) Difference(other *HashSet[TKey]) *HashSet[TKey]

Difference returns a new set containing all the elements that are in this set but not in the other set.

func (*HashSet[TKey]) Equal

func (self *HashSet[TKey]) Equal(other *HashSet[TKey]) bool

Equal returns true if the given set is equal to this set.

func (*HashSet[TKey]) Filter added in v0.3.0

func (self *HashSet[TKey]) Filter(fn func(TKey) bool) *HashSet[TKey]

func (*HashSet[TKey]) ForEach

func (self *HashSet[TKey]) ForEach(fn func(TKey))

func (*HashSet[TKey]) Intersection

func (self *HashSet[TKey]) Intersection(other *HashSet[TKey]) *HashSet[TKey]

Intersection returns a new set containing all the elements that are in both sets.

func (*HashSet[TKey]) IsEmpty

func (self *HashSet[TKey]) IsEmpty() bool

IsEmpty returns true if the set is empty.

func (*HashSet[TKey]) Iter added in v0.3.0

func (self *HashSet[TKey]) Iter() iterator.Iterator[TKey]

func (*HashSet[TKey]) MarshalJSON added in v0.3.0

func (self *HashSet[TKey]) MarshalJSON() ([]byte, error)

func (*HashSet[TKey]) Remove

func (self *HashSet[TKey]) Remove(key TKey)

Remove removes the given key from the set.

func (*HashSet[TKey]) RemoveBy

func (self *HashSet[TKey]) RemoveBy(predicate func(TKey) bool)

RemoveBy remove keys from the set if the given predicate returns true.

func (*HashSet[TKey]) Size

func (self *HashSet[TKey]) Size() int

Size returns the number of elements in the set.

func (*HashSet[TKey]) SubsetOf

func (self *HashSet[TKey]) SubsetOf(other *HashSet[TKey]) bool

SubsetOf returns true if the given set is a subset of this set.

func (*HashSet[TKey]) SupersetOf

func (self *HashSet[TKey]) SupersetOf(other *HashSet[TKey]) bool

SupersetOf returns true if the given set is a superset of this set.

func (*HashSet[TKey]) SymmetricDifference

func (self *HashSet[TKey]) SymmetricDifference(other *HashSet[TKey]) *HashSet[TKey]

SymmetricDifference returns a new set containing all the elements that are in this set or the other set but not in both.

func (*HashSet[TKey]) ToMap added in v0.2.0

func (self *HashSet[TKey]) ToMap() map[TKey]struct{}

func (*HashSet[TKey]) ToSlice

func (self *HashSet[TKey]) ToSlice() []TKey

ToSlice returns a slice containing all elements in the set.

func (*HashSet[TKey]) Union

func (self *HashSet[TKey]) Union(other *HashSet[TKey]) *HashSet[TKey]

Union returns a new set containing all the elements that are in either set.

func (*HashSet[TKey]) UnionAssign added in v0.3.0

func (self *HashSet[TKey]) UnionAssign(other *HashSet[TKey])

UnionAssign union another HashSet into self

func (*HashSet[TKey]) UnmarshalJSON added in v0.3.0

func (self *HashSet[TKey]) UnmarshalJSON(v []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL