Documentation
¶
Overview ¶
Package ds provides some utilities relating to data structures.
Index ¶
- func Copy[T any, ST ~[]T](arr ST) ST
- func FlatMap[T any, R any, ST ~[]T, SR ~[]R](arr ST, iteratee func(T) SR) SR
- func FlatMapError[T any, R any, ST ~[]T, SR ~[]R](arr ST, iteratee func(T) (SR, error)) (SR, error)
- func Limit[T any, ST ~[]T](arr ST, limit int) ST
- func Map[T any, R any, ST ~[]T](arr ST, iteratee func(T) R) []R
- func MapError[T any, R any, ST ~[]T](arr ST, iteratee func(T) (R, error)) ([]R, error)
- func MergeMap[K comparable, V any, M ~map[K]V](m1, m2 M) M
- func SortAsc[E any, K constraints.Ordered](key func(e E) K) func(e1, e2 E) int
- func SortCompose[E any](comparators ...func(e1, e2 E) int) func(e1, e2 E) int
- func SortDesc[E any, K constraints.Ordered](key func(e E) K) func(e1, e2 E) int
- func Uniq[E comparable, S ~[]E](sorted S) S
- type SyncMap
- func (m *SyncMap[K, V]) Copy() map[K]V
- func (m *SyncMap[K, V]) Delete(key K)
- func (m *SyncMap[K, V]) Load(key K) (value V, ok bool)
- func (m *SyncMap[K, V]) LoadAndDelete(key K) (value V, loaded bool)
- func (m *SyncMap[K, V]) LoadOrStore(key K, value V) (actual V, loaded bool)
- func (m *SyncMap[K, V]) Range(f func(key K, value V) bool)
- func (m *SyncMap[K, V]) Store(key K, value V)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FlatMapError ¶
func MergeMap ¶ added in v0.7.0
func MergeMap[K comparable, V any, M ~map[K]V](m1, m2 M) M
func SortCompose ¶
func Uniq ¶ added in v0.7.1
func Uniq[E comparable, S ~[]E](sorted S) S
Uniq compresses all successive duplicate elements in sorted slice, like unix command 'uniq'.
Types ¶
type SyncMap ¶ added in v0.3.4
type SyncMap[K comparable, V any] struct { // contains filtered or unexported fields }
SyncMap is a simple wrapper around sync.Map. https://www.reddit.com/r/golang/comments/twucb0/comment/j4x7xbx/
func (*SyncMap[K, V]) LoadAndDelete ¶ added in v0.3.4
func (*SyncMap[K, V]) LoadOrStore ¶ added in v0.3.4
Click to show internal directories.
Click to hide internal directories.