types

package
v0.0.0-...-f042742 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SortPairSlice

func SortPairSlice[First cmp.Ordered, Second any](pairs []Pair[First, Second])

Types

type Pair

type Pair[First cmp.Ordered, Second any] struct {
	First  First
	Second Second
}

func CollectMapToPairSlice

func CollectMapToPairSlice[Key cmp.Ordered, Value any](m map[Key]Value) []Pair[Key, Value]

type Set

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

Set is a simple set implementation.

func NewSet

func NewSet[K comparable](items ...K) Set[K]

NewSet creates a set from given items.

func (Set[K]) Add

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

Add adds an item to the set.

func (Set[K]) Contains

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

Contains returns true if item exists in the set.

func (Set[K]) Difference

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

Difference returns a new set with the items that are in this set but not in other.

func (Set[K]) Intersect

func (s Set[K]) Intersect(other Set[K]) Set[K]

Intersect returns a new set with items which are common between this set and the other set.

func (Set[K]) Remove

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

Remove removes an item from the set.

func (Set[K]) Slice

func (s Set[K]) Slice() []K

Slice takes a copy of the items in the set and returns it as a slice. The order of items is random.

func (Set[K]) Union

func (s Set[K]) Union(other Set[K]) Set[K]

Union returns a new set with all items in this set and the other set.

Jump to

Keyboard shortcuts

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