util

package module
v0.0.0-...-861193b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2023 License: MIT Imports: 5 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExitFatal

func ExitFatal(err error)

func ExitIfError

func ExitIfError[T any](v T, err error) T

func FilterMap

func FilterMap[K comparable, V any](m map[K]V, cb func(k K, v V) bool) map[K]V

Iterates over the input map, passing the key and value to the callback function for each iteration. Returns a new map containing only key+value pairs that pass the callback predicate (return true)

func FilterSlice

func FilterSlice[T any](s []T, cb func(i int, v T) bool) []T

Iterates over the input slice, passing the index and value to the callback function for each iteration. Returns a new slice containing only values that pass the callback predicate (return true)

func LoadInput

func LoadInput(fname string) (input []byte, err error)

func Map

func Map[T any, M any](s []T, cb func(i int, v T) M) []M

Iterates over the input array, passing the index and value to the callback function for each iteration. Returns a new array built from the return values of the callback function.

func MapContains

func MapContains[K comparable, V comparable](m map[K]V, v V) bool

Iterates over a map to see if the given value exists within the map.

func MapKeys

func MapKeys[K comparable, V any](m map[K]V) []K

Returns a slice containing all keys of the given map

func MapVals

func MapVals[K comparable, V any](m map[K]V) []V

Returns a slice containing all values of the given map

func Max

func Max[T cmp.Ordered](vals ...T) T

Returns the maximum value respective to the type of the values given

func Min

func Min[T cmp.Ordered](vals ...T) T

Returns the minimum value respective to the type of the values given

func PrintMap

func PrintMap[K comparable, V any](m map[K]V)

func PrintSlice

func PrintSlice[T any](s []T)

func SliceContains

func SliceContains[T comparable](s []T, v T) bool

Iterates over a slice to see if the given value exists within the slice.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL