set

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2023 License: Apache-2.0 Imports: 0 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

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

Set is a container that store unique elements in no particular order. Sets are an alias for map[T]struct{} where T is a comparable type.

func NewSet

func NewSet[T comparable](values ...T) Set[T]

NewSet creates a new Set from a list of values.

func (Set[T]) Add

func (s Set[T]) Add(values ...T)

Add adds a value to the set.

func (Set[T]) Contains

func (s Set[T]) Contains(value T) bool

Contains returns true if the set contains the value.

func (Set[T]) ContainsAll

func (s Set[T]) ContainsAll(values ...T) bool

ContainsAll returns true if the set contains all the values.

func (Set[T]) Remove

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

Remove removes a value from the set. Returns true if the set contained the value.

func (Set[T]) RemoveAll

func (s Set[T]) RemoveAll(values ...T)

RemoveAll removes all values from the set.

func (Set[T]) Slice

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

Slice returns a slice of the values in the set.

Jump to

Keyboard shortcuts

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