Documentation
¶
Index ¶
- func Abs[T SignedNumeric](a T) T
- func EqualSlice[T comparable](s, t []T) bool
- func GetMapKeys[K comparable, V any](m map[K]V) []K
- func IfTrue[T any](on bool, a T, b T) (rv T)
- func InArray[T comparable](needle T, haystack []T) bool
- func KeysForStringMap[T any](aMap map[string]T) (rv []string)
- func LocationInArray[T comparable](needle T, haystack []T) int
- func Max[T constraints.Ordered](a, b T) T
- func MaxArray[T constraints.Ordered](a []T) (rv T)
- func Min[T constraints.Ordered](a, b T) T
- func MinArray[T constraints.Ordered](a []T) (rv T)
- func Remove[T any](haystack []T, needle T) (result []T)
- func RemoveAt[T any](slice []T, pos int) []T
- func RemoveComparable[T comparable](slice []T, element T) (result []T)
- func SortSlice[T constraints.Ordered](s []T)
- func SortedKeysForStringMap[T any](aMap map[string]T) (rv []string)
- func ToBoolMap[T comparable](src []T) map[T]bool
- func Unique[T comparable](s []T) []T
- type Numeric
- type SignedInteger
- type SignedNumeric
- type Unsigned
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Abs ¶
func Abs[T SignedNumeric](a T) T
func EqualSlice ¶ added in v0.0.7
func EqualSlice[T comparable](s, t []T) bool
func GetMapKeys ¶ added in v0.0.6
func GetMapKeys[K comparable, V any](m map[K]V) []K
func InArray ¶
func InArray[T comparable](needle T, haystack []T) bool
InArray uses Dijkstra's "L" algorythm to search 'haystack' for 'needle'. "L" is the linear search algorythm. Exampel of Use:
func KeysForStringMap ¶
func LocationInArray ¶
func LocationInArray[T comparable](needle T, haystack []T) int
func Max ¶
func Max[T constraints.Ordered](a, b T) T
func MaxArray ¶
func MaxArray[T constraints.Ordered](a []T) (rv T)
func Min ¶
func Min[T constraints.Ordered](a, b T) T
func MinArray ¶
func MinArray[T constraints.Ordered](a []T) (rv T)
func Remove ¶ added in v0.0.14
func Remove[T any](haystack []T, needle T) (result []T)
Remove will take 'needle' from 'haystack' if it matches based on reflect.DeepEqual
func RemoveAt ¶ added in v0.0.12
RemoveAt removes from `slice` the item at postion `pos`. If pos is out of range it returns the original `slice`.
func RemoveComparable ¶ added in v0.0.14
func RemoveComparable[T comparable](slice []T, element T) (result []T)
func SortSlice ¶ added in v0.0.6
func SortSlice[T constraints.Ordered](s []T)
func SortedKeysForStringMap ¶ added in v0.0.10
SortedKeysForStringMap will Extract the keys from a map[string]interface{}, sort them and return the sorted slice.
func ToBoolMap ¶ added in v0.0.15
func ToBoolMap[T comparable](src []T) map[T]bool
ToBoolMap will convert a slice to a set of true flags in a map that can then be looked up in (or set to false to get rid of items)
For eample,
x := []string{ "a", "b" }
Will produce `x`, a map[string]bool with values of:
x == map[string]bool{ "a": true, "b": true }
func Unique ¶ added in v0.0.14
func Unique[T comparable](s []T) []T
Types ¶
type SignedInteger ¶
Signed is a constraint with a type set of all signed integer types.
type SignedNumeric ¶
SignedNumeric is a constraint with a type set of all signed types.