sets

package
v0.0.0-...-7d7b408 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Collect

func Collect[T comparable](s Set[T]) []T

Collects builds a slice containing all items in the set, in no particular order.

func Copy

func Copy[T comparable](dst, src Set[T])

Copy copies the items from src to dst.

func Equal

func Equal[S Set[T], T comparable](s1, s2 Set[T]) bool

Equal reports whether two sets contain the same values. Values are compared using ==.

func Insert

func Insert[T comparable](s Set[T], seq iter.Seq[T])

Insert adds the items from seq to the Set.

func Values

func Values[T comparable](s Set[T]) iter.Seq[T]

Values returns an interator over the Set values.

Types

type Set

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

Set is a collection of unique items.

To create a new set, use make(Set[T], cap).

func Append

func Append[T comparable](s Set[T], values ...T) Set[T]

Append is the same as Add, but it creates a new set if s is nil.

func (Set[T]) Add

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

Add adds values to an existing set.

func (Set[T]) Clone

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

Clone returns a copy of the Set.

func (Set[T]) Contains

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

Contains returns true if the Set contains the value. This operation has O(1) complexity.

func (Set[T]) Remove

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

Remove removes an item from an existing Set.

func (Set[T]) String

func (s Set[T]) String() string

Jump to

Keyboard shortcuts

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