sets

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2023 License: Apache-2.0 Imports: 3 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[E comparable] struct {
	// contains filtered or unexported fields
}

func FromIter added in v0.5.0

func FromIter[E comparable](s iter.Seq[E]) HashSet[E]

func FromMapKeys added in v0.5.0

func FromMapKeys[E comparable, TValue any, M ~map[E]TValue](m M) HashSet[E]

func NewHashSet

func NewHashSet[E comparable](elements ...E) HashSet[E]

NewHashSet returns a new empty hash set.

func (HashSet[E]) Add

func (self HashSet[E]) Add(keys ...E)

Add adds the given keys to the set.

func (HashSet[E]) AddAll

func (self HashSet[E]) AddAll(other HashSet[E])

AddAll adds all elements from another HashSet.

func (HashSet[E]) AddIter added in v0.5.0

func (self HashSet[E]) AddIter(s iter.Seq[E])

AddIter adds all elements in Iter.

func (HashSet[E]) Clear

func (self HashSet[E]) Clear()

Clear removes all keys from the set.

func (HashSet[E]) Clone

func (self HashSet[E]) Clone() HashSet[E]

Clone returns a copy of the set.

func (HashSet[E]) Contains

func (self HashSet[E]) Contains(key E) bool

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

func (HashSet[E]) ContainsAll

func (self HashSet[E]) ContainsAll(keys iter.Seq[E]) bool

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

func (HashSet[E]) ContainsAny

func (self HashSet[E]) ContainsAny(keys iter.Seq[E]) bool

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

func (HashSet[E]) DeepCloneBy

func (self HashSet[E]) DeepCloneBy(clone func(E) E) HashSet[E]

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

func (HashSet[E]) Difference

func (self HashSet[E]) Difference(other HashSet[E]) HashSet[E]

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

func (HashSet[E]) Equal

func (self HashSet[E]) Equal(other HashSet[E]) bool

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

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

func (self HashSet[E]) Filter(fn func(E) bool) HashSet[E]

func (HashSet[E]) Intersection

func (self HashSet[E]) Intersection(other HashSet[E]) HashSet[E]

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

func (HashSet[E]) IsEmpty

func (self HashSet[E]) IsEmpty() bool

IsEmpty returns true if the set is empty.

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

func (self HashSet[E]) Iter() iter.Seq[E]

Iter returns a iter.Seq that iterate over the keys in the set.

func (HashSet[E]) Map added in v0.4.0

func (self HashSet[E]) Map(fn func(E) E) HashSet[E]

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

func (self HashSet[E]) MarshalJSON() ([]byte, error)

func (HashSet[E]) Remove

func (self HashSet[E]) Remove(key E)

Remove removes the given key from the set.

func (HashSet[E]) RemoveBy

func (self HashSet[E]) RemoveBy(predicate func(E) bool)

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

func (HashSet[E]) Size

func (self HashSet[E]) Size() int

Size returns the number of elements in the set.

func (HashSet[E]) SubsetOf

func (self HashSet[E]) SubsetOf(other HashSet[E]) bool

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

func (HashSet[E]) SupersetOf

func (self HashSet[E]) SupersetOf(other HashSet[E]) bool

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

func (HashSet[E]) SymmetricDifference

func (self HashSet[E]) SymmetricDifference(other HashSet[E]) HashSet[E]

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

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

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

func (HashSet[E]) Union

func (self HashSet[E]) Union(other HashSet[E]) HashSet[E]

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

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

func (self HashSet[E]) UnionAssign(other HashSet[E])

UnionAssign union another HashSet into self

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

func (self HashSet[E]) UnmarshalJSON(v []byte) error

Jump to

Keyboard shortcuts

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