set

package
v1.0.0-beta Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2023 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 generic set implementation.

func New

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

New returns a new set based on the specified generic type (must be comparable).

func (Set[T]) Add

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

Add adds an item to the set. It returns the same set to allow easy chaining of Adds.

func (Set[T]) Contains

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

Contains simply checks if the item exists in the set.

func (Set[T]) MustRemove

func (s Set[T]) MustRemove(item T)

MustRemove removes an item from the set. However, it assumes that the item is present and it must be removed. It will panic if the item is not present.

func (Set[T]) Remove

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

Remove removes an item from the set. It will throw an error if the item is not present.

Jump to

Keyboard shortcuts

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