Documentation ¶
Overview ¶
Package ds provides some fundamental data structures.
Index ¶
- func AppendMap[K comparable, V any, M ~map[K]V](m *M, key K, value V)
- func Equals[T comparable](s, t []T) bool
- func FirstN[T any](s []T, n int) []T
- func LessFunc[E any, K constraints.Ordered](key func(e E) K) func(e1, e2 E) bool
- func Map[T, U any](s []T, mapper func(item T) U) []U
- func MergeMap[K comparable, V any](m1, m2 map[K]V) map[K]V
- func ReadAll[T any](ch <-chan T) []T
- func SliceOfPtr[T any](s []T) []*T
- type Mutex
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendMap ¶
func AppendMap[K comparable, V any, M ~map[K]V](m *M, key K, value V)
AppendMap appends key to the map, optionally initializing map if nil.
func Equals ¶
func Equals[T comparable](s, t []T) bool
func LessFunc ¶ added in v0.9.1
func LessFunc[E any, K constraints.Ordered](key func(e E) K) func(e1, e2 E) bool
func MergeMap ¶
func MergeMap[K comparable, V any](m1, m2 map[K]V) map[K]V
func SliceOfPtr ¶
func SliceOfPtr[T any](s []T) []*T
Types ¶
type Mutex ¶
type Mutex[K comparable] struct { // contains filtered or unexported fields }
Mutex is a simple replacement for golang.org/x/sync/singleflight. Includes ideas from https://cs.opensource.google/go/x/sync/+/master:singleflight/singleflight.go;drc=30421366ff761c80b137fb5084b32278ed41fab0.
func NewMutex ¶
func NewMutex[K comparable]() *Mutex[K]
Click to show internal directories.
Click to hide internal directories.