Documentation ¶
Overview ¶
Package rock generic based common package processing
Index ¶
- func ExtractArrUnique[T constraints.ValueIterable](count int, arr []T) []T
- func FormatKv[K constraints.KeyIterable, V any](data map[K]V) string
- func FormatList[V any](vList []V, joins ...string) string
- func FormatTable[V any](table [][]V, seps ...int) string
- func InList[T constraints.Equable](list []T, value T) bool
- func ListAny[T constraints.KeyIterable](vList []T) []any
- func ListEq[T constraints.Equable](list []T, compare []T) bool
- func ListGetOr[T any](list []T, index int, def T) T
- func ListIndex[T constraints.Equable](list []T, value T) (index int)
- func ListNoRepeat[T constraints.Equable](list []T) []T
- func ListRemove[T constraints.Equable](list []T, removes ...T) []T
- func ListSubset[T constraints.Equable](list []T, subset []T) bool
- func MapAssign[K constraints.KeyIterable, V any](source map[K]V, more ...map[K]V) map[K]V
- func MapFilter[K constraints.KeyIterable, V constraints.ValueIterable](kv map[K]V, filter []K) map[K]V
- func MapGenByKv[K constraints.KeyIterable, V constraints.ValueIterable](keys []K, values []V) (kv map[K]V)
- func MapKeys[T constraints.KeyIterable, X constraints.ValueIterable](vMap map[T]X) (keys []T)
- func MapKeysString[K constraints.KeyIterable, V any](data map[K]V) []string
- func MapSlice[K constraints.KeyIterable, V constraints.ValueIterable](kv map[K]V, filter []K) map[K]V
- func MapValues[T constraints.KeyIterable, X constraints.KeyIterable](vMap map[T]X) (values []X)
- func Param[T any](defValue T, args ...T) T
- func ParamFunc[T any](defFunc func() T, args ...T) T
- func ParamIndex[T any](index int, defValue T, args ...T) T
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractArrUnique ¶
func ExtractArrUnique[T constraints.ValueIterable](count int, arr []T) []T
ExtractArrUnique extracting array elements with loss (non-repeatable) from an array
func FormatKv ¶
func FormatKv[K constraints.KeyIterable, V any](data map[K]V) string
FormatKv @todo neet to test
Example ¶
s := FormatKv(map[string]any{ "name": "Joshua Conero", "meeting": 20.1, }) fmt.Println("列表输出如下:\n" + s)
Output: name Joshua Conero meeting 20.1
func FormatList ¶
Example ¶
s := FormatList([]string{"1", "this\\'s test", "box", "a", "must", "base", "念奴娇", "√√√√√", "", "saw", "no-list", "box", "box", "box", "box", "box", "box", "box", "box", "box", "box", "box", "box", "box", "box"}) fmt.Println("列表输出如下:\n" + s)
Output:
func FormatTable ¶
FormatTable two-dimensional array formatted output
func InList ¶
func InList[T constraints.Equable](list []T, value T) bool
InList determines whether a key value exists in the list
func ListAny ¶
func ListAny[T constraints.KeyIterable](vList []T) []any
ListAny data slice convert to any slice
func ListEq ¶
func ListEq[T constraints.Equable](list []T, compare []T) bool
ListEq Determines whether an array is equal
func ListGetOr ¶
ListGetOr Read element values through index or use default substitution (when not present)
func ListIndex ¶
func ListIndex[T constraints.Equable](list []T, value T) (index int)
ListIndex get index by search value from list
func ListNoRepeat ¶
func ListNoRepeat[T constraints.Equable](list []T) []T
ListNoRepeat filter duplicate elements in list
func ListRemove ¶
func ListRemove[T constraints.Equable](list []T, removes ...T) []T
ListRemove removes the specified element from the list
func ListSubset ¶
func ListSubset[T constraints.Equable](list []T, subset []T) bool
ListSubset determine whether the given subarray is accurate
func MapAssign ¶
func MapAssign[K constraints.KeyIterable, V any](source map[K]V, more ...map[K]V) map[K]V
MapAssign Merge multiple map parameters, where the same key value is the forward overwrite value.
And never return nil.
func MapFilter ¶
func MapFilter[K constraints.KeyIterable, V constraints.ValueIterable](kv map[K]V, filter []K) map[K]V
MapFilter use the keys of map to filter itself
func MapGenByKv ¶
func MapGenByKv[K constraints.KeyIterable, V constraints.ValueIterable](keys []K, values []V) (kv map[K]V)
MapGenByKv Create dictionary by key value pair array combination
func MapKeys ¶
func MapKeys[T constraints.KeyIterable, X constraints.ValueIterable](vMap map[T]X) (keys []T)
MapKeys Extract the key name array of the dictionary
func MapKeysString ¶
func MapKeysString[K constraints.KeyIterable, V any](data map[K]V) []string
func MapSlice ¶
func MapSlice[K constraints.KeyIterable, V constraints.ValueIterable](kv map[K]V, filter []K) map[K]V
MapSlice use the keys of map to slice itself
func MapValues ¶
func MapValues[T constraints.KeyIterable, X constraints.KeyIterable](vMap map[T]X) (values []X)
MapValues Extract the values name array of the dictionary
func Param ¶
func Param[T any](defValue T, args ...T) T
Param Extract indefinite parameters from functions and default code values
func ParamFunc ¶
func ParamFunc[T any](defFunc func() T, args ...T) T
ParamFunc Implementing parameter extraction through custom callback functions
func ParamIndex ¶
ParamIndex Gets parameters from the list according to the index, the index value starts with 1
Types ¶
This section is empty.
Directories ¶
Path | Synopsis |
---|---|
Package constraints The stereotype extension type definition is used for function /type annotations
|
Package constraints The stereotype extension type definition is used for function /type annotations |