ds

package
v1.10.41 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ds provides some fundamental data structures.

Index

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 DebouncedChan added in v1.9.0

func DebouncedChan[T any](ch <-chan T, period time.Duration) <-chan T

func Equals

func Equals[T comparable](s, t []T) bool

func FirstN added in v0.4.10

func FirstN[T any](s []T, n int) []T

func HasPrefix added in v1.2.2

func HasPrefix[T comparable](s, prefix []T) bool

func LessFunc added in v0.9.1

func LessFunc[E any, K cmp.Ordered](key func(e E) K) func(e1, e2 E) int

func Map added in v0.3.0

func Map[T, U any](s []T, mapper func(item T) U) []U

func MergeMap

func MergeMap[K comparable, V any](mm ...map[K]V) map[K]V

func MoreFunc added in v0.10.1

func MoreFunc[E any, K cmp.Ordered](key func(e E) K) func(e1, e2 E) int

func SliceOfPtr

func SliceOfPtr[T any](s []T) []*T

func UniqMergeSlice added in v0.19.0

func UniqMergeSlice[T comparable](s1, s2 []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]

func (*Mutex[K]) Lock

func (m *Mutex[K]) Lock(key K)

func (*Mutex[K]) TryLock

func (m *Mutex[K]) TryLock(key K) (ok bool)

func (*Mutex[K]) Unlock

func (m *Mutex[K]) Unlock(key K)

Jump to

Keyboard shortcuts

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