collection

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2022 License: Apache-2.0 Imports: 0 Imported by: 0

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 collection that only contains unique elements.

func MapSet

func MapSet[G any, T comparable](c []G, f func(G) T) Set[T]

MapSet allows to map a collection to a Set using a closure to extract the values of type T.

func NewSet

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

NewSet creates an empty Set.

func NewSetFrom

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

NewSetFrom creates a Set from a list of elements.

func (Set[T]) Add

func (s Set[T]) Add(e T)

Add stores a new element in the Set if wasn't contained yet.

func (Set[T]) Contains

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

Contains checks if an element is contained in the Set.

func (Set[T]) Delete

func (s Set[T]) Delete(e T)

Delete removes an element from the Set if it existed.

func (Set[T]) ToSlice

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

ToSlice generates a new slice with all elements in the Set. Order is non deterministic.

Jump to

Keyboard shortcuts

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