set

package
v2.0.0-...-a7294fb Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AreEqual

func AreEqual[T comparable](left, right Set[T]) bool

func AsSortedSlice

func AsSortedSlice[T constraints.Ordered](set Set[T]) []T

AsSortedSlice returns a sorted slice of values from this set

Types

type Set

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

Set provides a standard way to have a set of distinct things

func Make

func Make[T comparable](ts ...T) Set[T]

Make creates a new set with the given values

func Union

func Union[T comparable](sets ...Set[T]) Set[T]

Union returns the union of the specified sets

func (Set[T]) Add

func (set Set[T]) Add(x T)

Add adds the provided value into the set Nothing happens if the value is already present

func (Set[T]) AddAll

func (set Set[T]) AddAll(x Set[T])

AddAll adds the provided set into the existing set. Nothing happens for values which are already present

func (Set[T]) Clear

func (set Set[T]) Clear()

Clear removes all the items from this set.

func (Set[T]) Contains

func (set Set[T]) Contains(x T) bool

Contains does a check to see if the provided value is in the set

func (Set[T]) Copy

func (set Set[T]) Copy() Set[T]

Copy returns an independent copy of the set

func (Set[T]) Equals

func (set Set[T]) Equals(other Set[T]) bool

Equals checks to see if the two sets are equivalent

func (Set[T]) Except

func (set Set[T]) Except(other Set[T]) Set[T]

Except returns a new set with only the set of values which are not in the other set

func (Set[T]) Remove

func (set Set[T]) Remove(x T)

Remove deletes the provided value from the set Nothing happens if the value is not present

func (Set[T]) Values

func (set Set[T]) Values() []T

Values returns a slice of all the values in the set

func (Set[T]) Where

func (set Set[T]) Where(predicate func(T) bool) Set[T]

Where returns a new set with only the set of values which match the predicate

Jump to

Keyboard shortcuts

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