sets

package
v0.20.4 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

func List[T ordered](s Set[T]) []T

List returns the contents as a sorted T slice.

This is a separate function and not a method because not all types supported by Generic are ordered and only those can be sorted.

Types

type Set

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

func New

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

New creates a Set from a list of values.

func (Set[T]) Delete

func (s Set[T]) Delete(items ...T) Set[T]

Delete removes all items from the set.

func (Set[T]) Difference

func (s Set[T]) Difference(other Set[T]) Set[T]

Difference returns a set of objects that are not in other.

func (Set[T]) Equal

func (s Set[T]) Equal(other Set[T]) bool

Equal returns if both sets contain the same elements

func (Set[T]) Has

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

Has returns true if and only if item is contained in the set.

func (Set[T]) HasAny

func (s Set[T]) HasAny(items ...T) bool

HasAny returns true if any items are contained in the set.

func (Set[T]) Insert

func (s Set[T]) Insert(items ...T) Set[T]

Insert adds items to the set.

func (Set[T]) Intersection

func (s Set[T]) Intersection(o Set[T]) Set[T]

Intersection returns a new set which includes the item in BOTH s and other

func (Set[T]) Len

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

Len returns the size of the set.

Jump to

Keyboard shortcuts

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