Documentation
¶
Index ¶
- func All[K comparable, V any](m map[K]V, predicate func(key K, value V) bool) bool
- func Any[K comparable, V any](m map[K]V, predicate func(key K, value V) bool) bool
- func Count[K comparable, V any](m map[K]V, predicate func(key K, value V) bool) int
- func Drop[K comparable, V any](m map[K]V, n int) map[K]V
- func Each[K comparable, V any](m map[K]V, f func(key K, value V))
- func Filter[K comparable, V any](m map[K]V, predicate func(key K, value V) bool) map[K]V
- func Find[K comparable, V any](m map[K]V, predicate func(key K, value V) bool) (K, V, bool)
- func GroupBy[K comparable, V any, G comparable](m map[K]V, keyFunc func(key K, value V) G) map[G][]V
- func Invert[K comparable, V comparable](m map[K]V) map[V][]K
- func Keys[K comparable, V any](m map[K]V) []K
- func Map[K comparable, V any, R any](m map[K]V, f func(key K, value V) R) map[K]R
- func Max[K comparable, V any](m map[K]V, less func(a, b V) bool) (K, V, bool)
- func Merge[K comparable, V any](maps ...map[K]V) map[K]V
- func Min[K comparable, V any](m map[K]V, less func(a, b V) bool) (K, V, bool)
- func Partition[K comparable, V any](m map[K]V, predicate func(key K, value V) bool) (map[K]V, map[K]V)
- func Reduce[K comparable, V any, R any](m map[K]V, initial R, f func(acc R, key K, value V) R) R
- func Take[K comparable, V any](m map[K]V, n int) map[K]V
- func Values[K comparable, V any](m map[K]V) []V
- type SyncMap
- 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 All ¶
func All[K comparable, V any](m map[K]V, predicate func(key K, value V) bool) bool
All returns true if all key-value pairs satisfy the predicate
func Any ¶
func Any[K comparable, V any](m map[K]V, predicate func(key K, value V) bool) bool
Any returns true if any key-value pair satisfies the predicate
func Count ¶
func Count[K comparable, V any](m map[K]V, predicate func(key K, value V) bool) int
Count returns the number of key-value pairs that satisfy the predicate
func Drop ¶
func Drop[K comparable, V any](m map[K]V, n int) map[K]V
Drop returns the map with the first n key-value pairs removed
func Each ¶
func Each[K comparable, V any](m map[K]V, f func(key K, value V))
Each applies a function to each key-value pair in the map
func Filter ¶
func Filter[K comparable, V any](m map[K]V, predicate func(key K, value V) bool) map[K]V
Filter returns a new map containing only key-value pairs that satisfy the predicate
func Find ¶
func Find[K comparable, V any](m map[K]V, predicate func(key K, value V) bool) (K, V, bool)
Find returns the first key-value pair that satisfies the predicate, or false if none found
func GroupBy ¶
func GroupBy[K comparable, V any, G comparable](m map[K]V, keyFunc func(key K, value V) G) map[G][]V
GroupBy groups values by a key function
func Invert ¶
func Invert[K comparable, V comparable](m map[K]V) map[V][]K
Invert swaps keys and values (values must be comparable)
func Keys ¶
func Keys[K comparable, V any](m map[K]V) []K
Keys returns all keys from the map as a slice
func Map ¶
func Map[K comparable, V any, R any](m map[K]V, f func(key K, value V) R) map[K]R
Map transforms each value in the map using the provided function
func Max ¶
func Max[K comparable, V any](m map[K]V, less func(a, b V) bool) (K, V, bool)
Max returns the key-value pair with the maximum value according to the comparison function
func Merge ¶
func Merge[K comparable, V any](maps ...map[K]V) map[K]V
Merge combines multiple maps into one, with later maps taking precedence
func Min ¶
func Min[K comparable, V any](m map[K]V, less func(a, b V) bool) (K, V, bool)
Min returns the key-value pair with the minimum value according to the comparison function
func Partition ¶
func Partition[K comparable, V any](m map[K]V, predicate func(key K, value V) bool) (map[K]V, map[K]V)
Partition splits the map into two based on the predicate
func Reduce ¶
func Reduce[K comparable, V any, R any](m map[K]V, initial R, f func(acc R, key K, value V) R) R
Reduce accumulates values across the map using the provided function
func Take ¶
func Take[K comparable, V any](m map[K]V, n int) map[K]V
Take returns the first n key-value pairs from the map
func Values ¶
func Values[K comparable, V any](m map[K]V) []V
Values returns all values from the map as a slice
Types ¶
type SyncMap ¶
type SyncMap[K comparable, V any] struct { // contains filtered or unexported fields }