util

package module
v0.0.0-...-f257891 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2024 License: BSD-2-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IdentityFunc

func IdentityFunc[T any]() func(T) T

IdentityFunc returns identity function of type T

func MergeOrdered

func MergeOrdered[C cmp.Ordered, IN1, IN2, OUT []C](
	input1 IN1,
	input2 IN2,
) (out OUT)

MergeOrdered concatinates and sorts input1 and input2 and returns it. Parameters input1 and input2 must be sorted slices.

func MergeWithFunc

func MergeWithFunc[IN1, IN2, OUT any](
	input1 []IN1,
	input2 []IN2,
	cmp Comparer[IN1, IN2],
	conv1 Converter[IN1, OUT],
	conv2 Converter[IN2, OUT],
) (out []OUT)

MergeWithFunc merges input1 and input2 by comparing them with cmp function and constructing and returning a merged slice by using conv1, conv2 Converter functions.

func MergeWithFuncSimple

func MergeWithFuncSimple[T any](in1 []T, in2 []T, cmp Comparer[T, T]) []T

MergeWithFuncSimple merges input1 and input2 by comparing them with cmp function and constructing and returning a merged slice.

func SliceConvert

func SliceConvert[T any, V any](ts []T, converter Converter[T, V]) (vs []V)

SliceConvert converts slices with given converter function.

func UnmarshalReturn

func UnmarshalReturn[T any](data []byte) (*T, error)

UnmarshalReturn json.Unmarshal's to type T and returns it as a pointer.

func Zero

func Zero[T any]() T

Zero returns unassigned value of Type T

Types

type Comparer

type Comparer[T, V any] func(T, V) int

type Converter

type Converter[T any, V any] func(T) V

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳