set

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: MIT 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{}

func New

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

New returns a new set with the given items.

func (Set[T]) Add

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

Add adds an item to the set.

func (*Set[T]) Clear

func (s *Set[T]) Clear()

Clear removes all items from the set.

func (Set[T]) Filter

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

Filter returns a new set with all items that satisfy the given predicate.

func (Set[T]) ForEach

func (s Set[T]) ForEach(f func(T))

ForEach iterates over the set and calls the given function for each item.

func (Set[T]) Has

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

Has returns true if the item is in the set.

func (Set[T]) IsEmpty

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

IsEmpty returns true if the set is empty.

func (Set[T]) Len

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

Len returns the number of items in the set.

func (Set[T]) Map

func (s Set[T]) Map(f func(T) T) Set[T]

Map returns a new set with the result of applying the given function to each item.

func (Set[T]) Remove

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

Remove removes an item from the set.

func (Set[T]) ToSlice

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

ToSlice returns a slice containing all items in the set.

Jump to

Keyboard shortcuts

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