Documentation
¶
Overview ¶
Package map_ provides map processing helper functions
Index ¶
- func AppendKeys[M ~map[K]V, K comparable, V any](elements M, out []K) []K
- func AppendKeysConv[M ~map[K]V, K comparable, V, T any](elements M, converter func(K) (T, error), out []T) ([]T, error)
- func AppendKeysConvert[M ~map[K]V, K comparable, V, T any](elements M, converter func(K) T, out []T) []T
- func AppendValues[M ~map[K]V, K comparable, V any](elements M, out []V) []V
- func AppendValuesConv[M ~map[K]V, K comparable, V, T any](elements M, converter func(V) (T, error), out []T) ([]T, error)
- func AppendValuesConvert[M ~map[K]V, K comparable, V, T any](elements M, converter func(V) T, out []T) []T
- func Clone[M ~map[K]V, K comparable, V any](elements M) M
- func Contains[M ~map[K]V, K comparable, V any](m M, key K) (ok bool)
- func Conv[M ~map[K]V, K, Kto comparable, V, Vto any](elements M, converter func(K, V) (Kto, Vto, error)) (map[Kto]Vto, error)
- func Convert[M ~map[K]V, K, Kto comparable, V, Vto any](elements M, converter func(K, V) (Kto, Vto)) map[Kto]Vto
- func ConvertKeys[M ~map[K]V, K, Kto comparable, V any](elements M, converter func(K) Kto) map[Kto]V
- func ConvertValues[M ~map[K]V, V, Vto any, K comparable](elements M, converter func(V) Vto) map[K]Vto
- func DeepClone[M ~map[K]V, K comparable, V any](elements M, copier func(V) V) M
- func Empty[M ~map[K]V, K comparable, V any](val M) bool
- func Filter[M ~map[K]V, K comparable, V any](elements M, filter func(K, V) bool) map[K]V
- func FilterKeys[M ~map[K]V, K comparable, V any](elements M, filter func(K) bool) map[K]V
- func FilterValues[M ~map[K]V, K comparable, V any](elements M, filter func(V) bool) map[K]V
- func First[M ~map[K]V, K comparable, V any](elements M, condition func(K, V) bool) (k K, v V, ok bool)
- func ForEachKey[M ~map[K]V, K comparable, V any](elements M, consumer func(K))
- func ForEachOrderedValues[M ~map[K]V, K comparable, V any](order []K, elements M, consumer func(V))
- func ForEachValue[M ~map[K]V, K comparable, V any](elements M, consumer func(V))
- func Generate[K comparable, V any](next func() (K, V, bool, error)) (map[K]V, error)
- func GenerateResolv[K comparable, V any](next func() (K, V, bool, error), resolv func(bool, K, V, V) V) (map[K]V, error)
- func Get[M ~map[K]V, K comparable, V any](m M, key K) V
- func GetOk[M ~map[K]V, K comparable, V any](m M, key K) (val V, ok bool)
- func Getter[M ~map[K]V, K comparable, V any](m M) func(key K) V
- func GetterOk[M ~map[K]V, K comparable, V any](m M) func(key K) (V, bool)
- func HasAny[M ~map[K]V, K comparable, V any](elements M, condition func(K, V) bool) bool
- func KeyChecker[M ~map[K]V, K comparable, V any](m M) func(key K) (ok bool)
- func Keys[M ~map[K]V, K comparable, V any](elements M) []K
- func KeysConv[M ~map[K]V, K comparable, V, T any](elements M, converter func(K) (T, error)) ([]T, error)
- func KeysConvert[M ~map[K]V, K comparable, V, T any](elements M, converter func(K) T) []T
- func NotEmpty[M ~map[K]V, K comparable, V any](val M) bool
- func Of[K comparable, V any](elements ...c.KV[K, V]) map[K]V
- func Reduce[M ~map[K]V, K comparable, V any](elements M, merge func(K, K, V, V) (K, V)) (rk K, rv V)
- func Slice[M ~map[K]V, K comparable, V any, T any](elements M, converter func(key K, val V) T) []T
- func Slicee[M ~map[K]V, K comparable, V any, T any](elements M, converter func(key K, val V) (T, error)) ([]T, error)
- func ToString[M ~map[K]V, K comparable, V any](elements M) string
- func ToStringOrdered[M ~map[K]V, K comparable, V any](order []K, elements M) string
- func ToStringOrderedf[M ~map[K]V, K comparable, V any](order []K, elements M, kvFormat, delim string) string
- func ToStringf[M ~map[K]V, K comparable, V any](elements M, kvFormat, delim string) string
- func TrackEach[M ~map[K]V, K comparable, V any](elements M, consumer func(K, V))
- func TrackEachOrdered[M ~map[K]V, K comparable, V any](order []K, uniques M, consumer func(K, V))
- func TrackKeysWhile[M ~map[K]V, K comparable, V any](elements M, consumer func(K) bool)
- func TrackOrderedValuesWhile[M ~map[K]V, K comparable, V any](order []K, elements M, consumer func(int, V) bool)
- func TrackOrderedWhile[M ~map[K]V, K comparable, V any](order []K, elements M, consumer func(K, V) bool)
- func TrackValuesWhile[M ~map[K]V, K comparable, V any](elements M, consumer func(V) bool)
- func TrackWhile[M ~map[K]V, K comparable, V any](elements M, consumer func(K, V) bool)
- func Values[M ~map[K]V, K comparable, V any](elements M) []V
- func ValuesConv[M ~map[K]V, K comparable, V, T any](elements M, converter func(V) (T, error)) ([]T, error)
- func ValuesConvert[M ~map[K]V, K comparable, V, T any](elements M, converter func(V) T) []T
- func ValuesConverted[M ~map[K]V, K comparable, V, Vto any](elements M, by func(V) Vto) []Vto
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendKeys ¶ added in v0.0.7
func AppendKeys[M ~map[K]V, K comparable, V any](elements M, out []K) []K
AppendKeys collects keys of the 'elements' map into the 'out' slice
func AppendKeysConv ¶ added in v0.0.13
func AppendKeysConv[M ~map[K]V, K comparable, V, T any](elements M, converter func(K) (T, error), out []T) ([]T, error)
AppendKeysConv gets keys of the 'elements' map, converts and appends into the 'out' slice
func AppendKeysConvert ¶ added in v0.0.13
func AppendKeysConvert[M ~map[K]V, K comparable, V, T any](elements M, converter func(K) T, out []T) []T
AppendKeysConvert gets keys of the 'elements' map, converts and appends into the 'out' slice
func AppendValues ¶ added in v0.0.7
func AppendValues[M ~map[K]V, K comparable, V any](elements M, out []V) []V
AppendValues collects values of the 'elements' map into the 'out' slice
func AppendValuesConv ¶ added in v0.0.13
func AppendValuesConv[M ~map[K]V, K comparable, V, T any](elements M, converter func(V) (T, error), out []T) ([]T, error)
AppendValuesConv get values of the 'elements' map, converts and appends into the 'out' slice
func AppendValuesConvert ¶ added in v0.0.13
func AppendValuesConvert[M ~map[K]V, K comparable, V, T any](elements M, converter func(V) T, out []T) []T
AppendValuesConvert get values of the 'elements' map, converts and appends into the 'out' slice
func Clone ¶ added in v0.0.5
func Clone[M ~map[K]V, K comparable, V any](elements M) M
Clone makes a copy of the 'elements' map. The values are copied as is.
func Contains ¶ added in v0.0.10
func Contains[M ~map[K]V, K comparable, V any](m M, key K) (ok bool)
Contains checks is the map contains a key
func Conv ¶ added in v0.0.8
func Conv[M ~map[K]V, K, Kto comparable, V, Vto any](elements M, converter func(K, V) (Kto, Vto, error)) (map[Kto]Vto, error)
Conv creates a map with converted keys and values
func Convert ¶ added in v0.0.8
func Convert[M ~map[K]V, K, Kto comparable, V, Vto any](elements M, converter func(K, V) (Kto, Vto)) map[Kto]Vto
Convert creates a map with converted keys and values
func ConvertKeys ¶ added in v0.0.8
func ConvertKeys[M ~map[K]V, K, Kto comparable, V any](elements M, converter func(K) Kto) map[Kto]V
ConvertKeys creates a map with converted keys
func ConvertValues ¶ added in v0.0.5
func ConvertValues[M ~map[K]V, V, Vto any, K comparable](elements M, converter func(V) Vto) map[K]Vto
ConvertValues creates a map with converted values
func DeepClone ¶ added in v0.0.5
func DeepClone[M ~map[K]V, K comparable, V any](elements M, copier func(V) V) M
DeepClone makes a copy of the 'elements' map. The values are copied by the 'copier' function
func Empty ¶ added in v0.0.8
func Empty[M ~map[K]V, K comparable, V any](val M) bool
Empty checks the val map is empty
func Filter ¶ added in v0.0.10
func Filter[M ~map[K]V, K comparable, V any](elements M, filter func(K, V) bool) map[K]V
Filter creates a map containing only the filtered elements
func FilterKeys ¶ added in v0.0.10
func FilterKeys[M ~map[K]V, K comparable, V any](elements M, filter func(K) bool) map[K]V
FilterKeys creates a map containing only the filtered elements
func FilterValues ¶ added in v0.0.10
func FilterValues[M ~map[K]V, K comparable, V any](elements M, filter func(V) bool) map[K]V
FilterValues creates a map containing only the filtered elements
func First ¶ added in v0.0.17
func First[M ~map[K]V, K comparable, V any](elements M, condition func(K, V) bool) (k K, v V, ok bool)
First returns the first key\value pair that satisfies the condition.
func ForEachKey ¶
func ForEachKey[M ~map[K]V, K comparable, V any](elements M, consumer func(K))
ForEachKey applies the 'consumer' function for every key from the 'elements' map
func ForEachOrderedValues ¶
func ForEachOrderedValues[M ~map[K]V, K comparable, V any](order []K, elements M, consumer func(V))
ForEachOrderedValues applies the 'consumer' function for each value from the 'elements' map in order of the 'order' slice
func ForEachValue ¶
func ForEachValue[M ~map[K]V, K comparable, V any](elements M, consumer func(V))
ForEachValue applies the 'consumer' function for every value from the 'elements' map
func Generate ¶ added in v0.0.5
func Generate[K comparable, V any](next func() (K, V, bool, error)) (map[K]V, error)
Generate builds a map by an generator function. The next returns a key\value pair, or false if the generation is over, or an error.
func GenerateResolv ¶ added in v0.0.5
func GenerateResolv[K comparable, V any](next func() (K, V, bool, error), resolv func(bool, K, V, V) V) (map[K]V, error)
GenerateResolv builds a map by an generator function. The next returns a key\value pair, or false if the generation is over, or an error. The resolv selects value for duplicated keys.
func Get ¶ added in v0.0.10
func Get[M ~map[K]V, K comparable, V any](m M, key K) V
Get returns the value by the specified key from the map m or zero if the map doesn't contain that key
func GetOk ¶ added in v0.0.10
func GetOk[M ~map[K]V, K comparable, V any](m M, key K) (val V, ok bool)
GetOk returns the value, and true by the specified key from the map m or zero and false if the map doesn't contain that key
func Getter ¶ added in v0.0.10
func Getter[M ~map[K]V, K comparable, V any](m M) func(key K) V
Getter creates a function that can be used for retrieving a value from the map m by a key
func GetterOk ¶ added in v0.0.10
func GetterOk[M ~map[K]V, K comparable, V any](m M) func(key K) (V, bool)
GetterOk creates a function that can be used for retrieving a value from the map m by a key
func HasAny ¶ added in v0.0.7
func HasAny[M ~map[K]V, K comparable, V any](elements M, condition func(K, V) bool) bool
HasAny checks whether the elements contains an key\value pair that satisfies the condition.
func KeyChecker ¶ added in v0.0.10
func KeyChecker[M ~map[K]V, K comparable, V any](m M) func(key K) (ok bool)
KeyChecker creates a function that can be used to check if the map contains a key
func Keys ¶
func Keys[M ~map[K]V, K comparable, V any](elements M) []K
Keys returns keys of the 'elements' map as a slice
func KeysConv ¶ added in v0.0.13
func KeysConv[M ~map[K]V, K comparable, V, T any](elements M, converter func(K) (T, error)) ([]T, error)
KeysConv gets keys of the 'elements' map, converts and returns as a slice
func KeysConvert ¶ added in v0.0.13
func KeysConvert[M ~map[K]V, K comparable, V, T any](elements M, converter func(K) T) []T
KeysConvert gets keys of the 'elements' map, converts and returns as a slice
func NotEmpty ¶ added in v0.0.8
func NotEmpty[M ~map[K]V, K comparable, V any](val M) bool
NotEmpty checks the val map is not empty
func Of ¶ added in v0.0.7
func Of[K comparable, V any](elements ...c.KV[K, V]) map[K]V
Of instantiates a ap from the specified key/value pairs
func Reduce ¶ added in v0.0.7
func Reduce[M ~map[K]V, K comparable, V any](elements M, merge func(K, K, V, V) (K, V)) (rk K, rv V)
Reduce reduces the key/value pairs by the 'next' function into an one pair using the 'merge' function. If the 'elements' map is empty, the zero values of 'K', 'V' types are returned.
func Slice ¶ added in v0.0.14
func Slice[M ~map[K]V, K comparable, V any, T any](elements M, converter func(key K, val V) T) []T
Slice collects key\value elements to a slice by applying the specified converter to evety element
func Slicee ¶ added in v0.0.14
func Slicee[M ~map[K]V, K comparable, V any, T any](elements M, converter func(key K, val V) (T, error)) ([]T, error)
Slicee collects key\value elements to a slice by applying the specified erroreable converter to evety element
func ToString ¶
func ToString[M ~map[K]V, K comparable, V any](elements M) string
ToString converts elements to the string representation
func ToStringOrdered ¶
func ToStringOrdered[M ~map[K]V, K comparable, V any](order []K, elements M) string
ToStringOrdered converts elements to the string representation according to the order
func ToStringOrderedf ¶
func ToStringOrderedf[M ~map[K]V, K comparable, V any](order []K, elements M, kvFormat, delim string) string
ToStringOrderedf converts elements to a string representation using a key/value pair format and a delimeter. In order
func ToStringf ¶
func ToStringf[M ~map[K]V, K comparable, V any](elements M, kvFormat, delim string) string
ToStringf converts elements to a string representation using a key/value pair format and a delimeter
func TrackEach ¶
func TrackEach[M ~map[K]V, K comparable, V any](elements M, consumer func(K, V))
TrackEach applies the 'consumer' function for every key/value pairs from the 'elements' map
func TrackEachOrdered ¶
func TrackEachOrdered[M ~map[K]V, K comparable, V any](order []K, uniques M, consumer func(K, V))
TrackEachOrdered applies the 'consumer' function for evey key/value pair from the 'elements' map in order of the 'order' slice
func TrackKeysWhile ¶ added in v0.0.12
func TrackKeysWhile[M ~map[K]V, K comparable, V any](elements M, consumer func(K) bool)
TrackKeysWhile applies the 'consumer' function for every key from the 'elements' map until the consumer returns false.
func TrackOrderedValuesWhile ¶ added in v0.0.12
func TrackOrderedValuesWhile[M ~map[K]V, K comparable, V any](order []K, elements M, consumer func(int, V) bool)
TrackOrderedValuesWhile applies the 'consumer' function for every value from the 'elements' map in order of the 'order' slice until the consumer returns false.
func TrackOrderedWhile ¶ added in v0.0.12
func TrackOrderedWhile[M ~map[K]V, K comparable, V any](order []K, elements M, consumer func(K, V) bool)
TrackOrderedWhile applies the 'consumer' function for every key/value pairs from the 'elements' map in order of the 'order' slice until the consumer returns false.
func TrackValuesWhile ¶ added in v0.0.12
func TrackValuesWhile[M ~map[K]V, K comparable, V any](elements M, consumer func(V) bool)
TrackValuesWhile applies the 'consumer' function for every value from the 'elements' map until the consumer returns false.
func TrackWhile ¶ added in v0.0.12
func TrackWhile[M ~map[K]V, K comparable, V any](elements M, consumer func(K, V) bool)
TrackWhile applies the 'consumer' function for every key/value pairs from the 'elements' map until the consumer returns false.
func Values ¶ added in v0.0.5
func Values[M ~map[K]V, K comparable, V any](elements M) []V
Values returns values of the 'elements' map as a slice
func ValuesConv ¶ added in v0.0.13
func ValuesConv[M ~map[K]V, K comparable, V, T any](elements M, converter func(V) (T, error)) ([]T, error)
ValuesConv gets values of the 'elements' map, converts and returns as a slice
func ValuesConvert ¶ added in v0.0.13
func ValuesConvert[M ~map[K]V, K comparable, V, T any](elements M, converter func(V) T) []T
ValuesConvert gets values of the 'elements' map, converts and returns as a slice
func ValuesConverted ¶ added in v0.0.5
func ValuesConverted[M ~map[K]V, K comparable, V, Vto any](elements M, by func(V) Vto) []Vto
ValuesConverted makes a slice of converted map values
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package clone provides map clone aliases
|
Package clone provides map clone aliases |
|
Package filter provides helpers for filtering keys or values of a map
|
Package filter provides helpers for filtering keys or values of a map |
|
Package resolv provides values resolvers for maps that builded by ToMap-converter functions
|
Package resolv provides values resolvers for maps that builded by ToMap-converter functions |