collections

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package collections provides small generic collection primitives shared across the handwritten Go, so a site carries a typed value instead of reimplementing a set operation or a keyed lookup locally.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyedList

type KeyedList[K comparable, V any] struct {
	// contains filtered or unexported fields
}

KeyedList is a list of values each carrying a key of type K.

func NewKeyedList

func NewKeyedList[K comparable, V any](key func(V) K, values []V) KeyedList[K, V]

NewKeyedList returns a keyed list looked up by the key each value carries.

func (KeyedList[K, V]) Get

func (list KeyedList[K, V]) Get(key K) (V, bool)

Get returns the value whose key is key, or the zero value and false when no value carries that key.

type Set

type Set[T comparable] []T

Set is a set of comparable values, kept as a slice without duplicates.

func (Set[T]) Remove

func (set Set[T]) Remove(value T) (Set[T], bool)

Remove returns the set with value removed, and whether value was present.

func (Set[T]) Toggle

func (set Set[T]) Toggle(value T) Set[T]

Toggle returns the set with value removed when it is present and added when it is absent.

Jump to

Keyboard shortcuts

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