sets

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: Apache-2.0 Imports: 2 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]

FromIter create a HashSet from iter.Seq.

func FromMapKeys added in v0.5.0

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

func FromSlice added in v0.6.0

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

FromSlice returns a new empty hash set.

func New added in v0.6.0

func New[E comparable]() HashSet[E]

func (HashSet[E]) Add

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

Add adds the given key to the set.

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

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

AddIter adds all elements in iter.Seq to the set.

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]) DifferenceIter added in v0.6.0

func (self HashSet[E]) DifferenceIter(it iter.Seq[E]) HashSet[E]

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]) EqualIter added in v0.6.0

func (self HashSet[E]) EqualIter(it iter.Seq[E]) bool

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]) IntersectionIter added in v0.6.0

func (self HashSet[E]) IntersectionIter(it iter.Seq[E]) HashSet[E]

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]) IterMut added in v0.6.0

func (self HashSet[E]) IterMut() iter.Seq[*SetItem[E]]

func (HashSet[E]) Remove

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

Remove removes the given key from the set.

func (HashSet[E]) RemoveIter added in v0.6.0

func (self HashSet[E]) RemoveIter(it iter.Seq[E])

RemoveIter removes all elements in iter.Seq.

func (HashSet[E]) Retain added in v0.6.0

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

Retain keep element that match the given predicate function.

Otherwise, remove from HashSet.

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]) SubsetOfIter added in v0.6.0

func (self HashSet[E]) SubsetOfIter(it iter.Seq[E]) bool

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]) SupersetOfIter added in v0.6.0

func (self HashSet[E]) SupersetOfIter(it iter.Seq[E]) bool

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]) SymmetricDifferenceIter added in v0.6.0

func (self HashSet[E]) SymmetricDifferenceIter(it iter.Seq[E]) HashSet[E]

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]) UnionIter added in v0.6.0

func (self HashSet[E]) UnionIter(it iter.Seq[E]) HashSet[E]

type SetItem added in v0.6.0

type SetItem[E comparable] struct {
	// contains filtered or unexported fields
}

func (*SetItem[E]) Remove added in v0.6.0

func (s *SetItem[E]) Remove()

func (*SetItem[E]) Value added in v0.6.0

func (s *SetItem[E]) Value() E

Jump to

Keyboard shortcuts

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