methods

package
v1.0.21 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: Apache-2.0 Imports: 7 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrArrayChunkSize = errors.New("size must be greater than 0")
)
View Source
var (
	ErrArraySliceOffset = errors.New("offset must be less than length array")
)
View Source
var (
	ErrMapCombine = errors.New("slices must has equal length")
)

Functions

func ArrayChunk

func ArrayChunk[S ~[]T, T any](s S, size int) ([]S, error)

func ArrayCopy

func ArrayCopy[S ~[]T, T any](s S) S

func ArrayDiff

func ArrayDiff[S ~[]T, T comparable](first, second S) S

func ArrayFill

func ArrayFill[S ~[]T, T any](startIndex int, num int, value T) S

func ArrayFilter

func ArrayFilter[S ~[]T, T any](f ArrayFilterFunc[T], s S) S

func ArrayFlip

func ArrayFlip[S ~[]T, T comparable](s S) map[T]int

func ArrayInsert added in v1.0.2

func ArrayInsert[S ~[]T, T any](s *S, indx int, elems ...T)

func ArrayIntersect

func ArrayIntersect[S ~[]T, T comparable](first, second S) S

func ArrayMap

func ArrayMap[S ~[]T, T any](f ArrayMapFunc[T], s S) S

func ArrayMax

func ArrayMax[S ~[]T, T constraints.Ordered](s S) T

func ArrayMerge

func ArrayMerge[S ~[]T, T any](arrs ...S) S

func ArrayMin

func ArrayMin[S ~[]T, T constraints.Ordered](s S) T

func ArrayPad

func ArrayPad[S ~[]T, T any](s S, size int, val T) S

func ArrayPop

func ArrayPop[S ~[]T, T any](s *S) T

func ArrayPush

func ArrayPush[S ~[]T, T any](s *S, elements ...T)

func ArrayRand

func ArrayRand[S ~[]T, T any](elements S) S

func ArrayReduce

func ArrayReduce[S ~[]T, T any](f ArrayReduceFunc[T], s S, init T) T

func ArrayRemove

func ArrayRemove[S ~[]T, T any](s *S, indx int)

func ArrayReverse

func ArrayReverse[S ~[]T, T any](s S) S

func ArrayShift

func ArrayShift[S ~[]T, T any](s *S) T

func ArraySlice

func ArraySlice[S ~[]T, T any](s S, offset, length int) (S, error)

func ArrayStructToArrayValuesByField added in v1.0.12

func ArrayStructToArrayValuesByField[S ~[]T, T, M any](s S, fields []string) []M

func ArrayStructToMapByField

func ArrayStructToMapByField[S ~[]T, T any, O comparable](s S, fields []string) map[O]T

func ArrayToMapValues

func ArrayToMapValues[S ~[]T, T comparable](s S) map[T]struct{}

func ArrayToMapValuesBool added in v1.0.16

func ArrayToMapValuesBool[S ~[]T, T comparable](s S) map[T]bool

func ArrayUnique

func ArrayUnique[S ~[]T, T comparable](s S) S

func ArrayUnshift

func ArrayUnshift[S ~[]T, T any](s *S, elements ...T)

func InArray

func InArray[S ~[]T, T comparable](s S, needle T) bool

func InMap

func InMap[M ~map[K]V, K, V comparable](m M, needle V) bool

func MapCombine

func MapCombine[M ~map[K]V, K, V comparable](s1 []K, s2 []V) (M, error)

func MapFlip

func MapFlip[M ~map[K]V, R ~map[V]K, K, V comparable](m M) R

func MapKeys

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

func MapValues

func MapValues[M ~map[K]V, K comparable, V any](m M) []V

func Ternary

func Ternary[T any](cond bool, first, second T) T

Types

type ArrayFilterFunc

type ArrayFilterFunc[T any] func(elem T) bool

type ArrayMapFunc

type ArrayMapFunc[T any] func(elem T) T

type ArrayReduceFunc

type ArrayReduceFunc[T any] func(first, second T) T

Jump to

Keyboard shortcuts

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