set

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option added in v1.0.3

type Option func(*Options)

func WithCapacity added in v1.0.3

func WithCapacity(capacity int) Option

type Options added in v1.0.3

type Options struct {
	// contains filtered or unexported fields
}

type Set

type Set[T comparable] map[T]struct{}

Set is a set of elements.

func New

func New[T comparable](options ...Option) Set[T]

New creates a new set with the given options.

func NewFromElements added in v1.0.3

func NewFromElements[T comparable](elements ...T) Set[T]

NewFromElements creates a new set with the given elements.

func NewFromSeq

func NewFromSeq[T comparable](source iter.Seq[T]) Set[T]

NewFromSeq creates a new set with the elements of the sequence.

func NewFromSet

func NewFromSet[T comparable](source Set[T]) Set[T]

NewFromSet creates a new set with the elements of the other set.

func NewFromSlice

func NewFromSlice[T comparable](source []T) Set[T]

NewFromSlice creates a new set with the elements of the slice.

func (Set[T]) Add

func (s Set[T]) Add(element T) bool

Add adds the element to the set. Returns true if the element was added. Returns false if the element was already in the set.

func (Set[T]) AddMany

func (s Set[T]) AddMany(elements ...T)

AddMany adds the elements to the set.

func (Set[T]) AddSeq

func (s Set[T]) AddSeq(source iter.Seq[T])

AddSeq adds the elements of the sequence to the set.

func (Set[T]) AddSet

func (s Set[T]) AddSet(source Set[T])

AddSet adds the elements of the other set to the set.

func (Set[T]) AddSlice

func (s Set[T]) AddSlice(source []T)

AddSlice adds the elements of the slice to the set.

func (Set[T]) All

func (s Set[T]) All(f func(T) bool) bool

All returns true if all elements in set satisfy the predicate f. If set is empty, All returns true.

func (Set[T]) Any

func (s Set[T]) Any(f func(T) bool) bool

Any returns true if any element in set satisfies the predicate, false otherwise. If set is empty, Any returns false.

func (Set[T]) Clear

func (s Set[T]) Clear()

Clear removes all elements from the set.

func (Set[T]) Clone

func (s Set[T]) Clone() Set[T]

Clone returns a copy of the set.

func (Set[T]) Contains

func (s Set[T]) Contains(elements ...T) bool

Contains returns true if the set contains all elements.

func (Set[T]) ContainsAny

func (s Set[T]) ContainsAny(elements ...T) bool

ContainsAny returns true if the set contains any of the elements.

func (Set[T]) ContainsAnyFromSeq

func (s Set[T]) ContainsAnyFromSeq(source iter.Seq[T]) bool

ContainsAnyFromSeq returns true if the set contains any of the elements of the sequence.

func (Set[T]) ContainsAnyFromSet

func (s Set[T]) ContainsAnyFromSet(other Set[T]) bool

ContainsAnyFromSet returns true if the set contains any of the elements of the other set.

func (Set[T]) ContainsAnyFromSlice

func (s Set[T]) ContainsAnyFromSlice(source []T) bool

ContainsAnyFromSlice returns true if the set contains any of the elements of the slice.

func (Set[T]) ContainsSeq

func (s Set[T]) ContainsSeq(source iter.Seq[T]) bool

ContainsSeq returns true if the set contains all elements of the sequence.

func (Set[T]) ContainsSet

func (s Set[T]) ContainsSet(other Set[T]) bool

ContainsSet returns true if the set contains all elements of the other set.

func (Set[T]) ContainsSlice

func (s Set[T]) ContainsSlice(source []T) bool

ContainsSlice returns true if the set contains all elements of the slice.

func (Set[T]) Count

func (s Set[T]) Count(f func(T) bool) int

Count returns the number of elements in set that satisfy the predicate f.

func (Set[T]) Diff

func (s Set[T]) Diff(other Set[T]) Set[T]

Diff returns the difference between the set and another set.

func (Set[T]) Equal

func (s Set[T]) Equal(other Set[T]) bool

Equal returns true if the set is equal to another set.

func (Set[T]) Filter

func (s Set[T]) Filter(f func(T) bool) Set[T]

Filter returns a new set containing only the elements that satisfy the predicate f.

func (Set[T]) IsEmpty

func (s Set[T]) IsEmpty() bool

IsEmpty returns true if the set is empty.

func (Set[T]) IsProperSubsetOf

func (s Set[T]) IsProperSubsetOf(other Set[T]) bool

IsProperSubsetOf returns true if the set is a proper subset of the other set.

func (Set[T]) IsProperSupersetOf

func (s Set[T]) IsProperSupersetOf(other Set[T]) bool

IsProperSupersetOf returns true if the set is a proper superset of the other set.

func (Set[T]) IsSubsetOf

func (s Set[T]) IsSubsetOf(other Set[T]) bool

IsSubsetOf returns true if the set is a subset of the other set.

func (Set[T]) IsSupersetOf

func (s Set[T]) IsSupersetOf(other Set[T]) bool

IsSupersetOf returns true if the set is a superset of the other set.

func (Set[T]) Len

func (s Set[T]) Len() int

Len returns the number of elements in the set.

func (Set[T]) Remove

func (s Set[T]) Remove(element T) bool

Remove removes the element from the set. Returns true if the element was removed. Returns false if the element was not in the set.

func (Set[T]) RemoveMany

func (s Set[T]) RemoveMany(elements ...T)

RemoveMany removes the elements from the set.

func (Set[T]) RemoveSeq

func (s Set[T]) RemoveSeq(source iter.Seq[T])

RemoveSeq removes the elements of the sequence from the set.

func (Set[T]) RemoveSet

func (s Set[T]) RemoveSet(source Set[T])

RemoveSet removes the elements of the other set from the set.

func (Set[T]) RemoveSlice

func (s Set[T]) RemoveSlice(source []T)

RemoveSlice removes the elements of the slice from the set.

func (Set[T]) SymmetricDiff

func (s Set[T]) SymmetricDiff(other Set[T]) Set[T]

SymmetricDiff returns the symmetric difference between the set and another set.

func (Set[T]) ToSeq

func (s Set[T]) ToSeq() iter.Seq[T]

func (Set[T]) ToSlice

func (s Set[T]) ToSlice() []T

func (Set[T]) Union

func (s Set[T]) Union(other Set[T]) Set[T]

Union returns the union of the set and another set.

Jump to

Keyboard shortcuts

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