sets

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 15, 2022 License: Apache-2.0 Imports: 1 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] 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]) 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 of 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 of 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]) 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 of 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]) 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 of the elements that are in this set or the other set but not in both.

func (HashSet[TKey]) ToSlice

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

ToSlice returns a slice containing all of the 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 of the elements that are in either set.

Jump to

Keyboard shortcuts

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