utils

package
v0.0.0-...-6bc7ac3 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply[T any](items []T, f func(T))

func CompareArrays

func CompareArrays[T comparable](a, b []T) (bool, int)

func Contains

func Contains[T any](items []T, f func(T) bool) bool

func ContainsElement

func ContainsElement[T comparable](elements []T, element T) bool

func Copy

func Copy[T any](items []T) []T

func CopyMap

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

func Count

func Count[T comparable](items []T, value T) int

func CountAny

func CountAny[T any](items []T, f func(T) bool) int

func DoesMapContain

func DoesMapContain[K comparable, V any](m map[K]V, f func(K, V) bool) bool

func DoesMapNotContain

func DoesMapNotContain[K comparable, V any](m map[K]V, f func(K, V) bool) bool

func DoesNotContain

func DoesNotContain[T any](items []T, f func(T) bool) bool

func DropFirstElement

func DropFirstElement[T any](elements []T) []T

func DropFromLeft

func DropFromLeft[T any](elements []T, n int) []T

func DropFromRight

func DropFromRight[T any](elements []T, n int) []T

func DropLastElement

func DropLastElement[T any](elements []T) []T

func Factorial

func Factorial(number int) int

func FillArray

func FillArray[T any](value T, numElements int) []T

func Filter

func Filter[V any](values []V, condition func(V) bool) []V

func FilterMap

func FilterMap[K comparable, V any](m map[K]V, condition func(K, V) bool) map[K]V

func Find

func Find[T any](items []T, f func(T) bool) *T

func FindInMap

func FindInMap[K comparable, V any](m map[K]V, f func(K, V) bool, defaultKey K, defaultValue V) (K, V, bool)

func FindIndex

func FindIndex[T any](items []T, f func(T) bool) int

func FindKey

func FindKey[K comparable, V any](m map[K]V, f func(K, V) bool, defaultValue K) (K, bool)

func FindLast

func FindLast[T any](items []T, f func(T) bool) *T

func FindLastIndex

func FindLastIndex[T any](items []T, f func(T) bool) int

func FindPointer

func FindPointer[T any](items []*T, f func(*T) bool) *T

func FindValue

func FindValue[K comparable, V any](m map[K]V, f func(K, V) bool, defaultValue V) (V, bool)

func FlatMap

func FlatMap[T any, O any](items []T, f func(T) []O) []O

func FlatMapParallel

func FlatMapParallel[T any, O any](items []T, f func(T) ([]O, error)) ([]O, error)

func Flatten

func Flatten[T any](items [][]T) []T

func Fold

func Fold[T any, O any](items []T, initial O, f func(O, T) O) O

func ForEach

func ForEach[T any](items []T, f func(T))

func GenerateRandomString

func GenerateRandomString(str string) string

func GenerateUniqueHash

func GenerateUniqueHash() string

func GenerateUniquePermutations

func GenerateUniquePermutations(numTrue, numFalse int) [][]bool

Function to generate all unique permutations of an array with numTrue true values and numFalse false values

func GetFirst

func GetFirst[T any](items []T) T

func GetKeys

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

func GetLast

func GetLast[T any](items []T) T

func GetSecondFromLast

func GetSecondFromLast[T any](items []T) T

func GetShuffledCopy

func GetShuffledCopy[T any](items []T) []T

func GetValues

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

func HasUniqueElements

func HasUniqueElements[T comparable](items []T) bool

func InsertAtIndex

func InsertAtIndex[T any](items []T, index int, value T) []T

func Map

func Map[T any, O any](items []T, f func(T) O) []O

func MapEntries

func MapEntries[K comparable, V any, O any](m map[K]V, f func(K, V) O) []O

func MapParallel

func MapParallel[T any, O any](items []T, f func(T) (O, error)) ([]O, error)

func MapToArray

func MapToArray[K comparable, V any, O any](m map[K]V, f func(K, V) O) []O

func MapToMap

func MapToMap[K comparable, V any, O any](m map[K]V, f func(K, V) O) map[K]O

func MapToPointerArray

func MapToPointerArray[K comparable, V any, O any](m map[K]V, f func(K, V) *O) []*O

func Max

func Max[T constraints.Ordered](a, b T) T

func MaxOver

func MaxOver[T cmp.Ordered](items []T) T

func MaxValue

func MaxValue(values []int) int

func Mean

func Mean[T Number](values []T) float64

func Min

func Min[T constraints.Ordered](a, b T) T

func MinOver

func MinOver[T cmp.Ordered](items []T) T

func NewIntArray

func NewIntArray(start, end int) []int

func ParallelContains

func ParallelContains[T any](items []T, f func(T) bool) bool

func ParallelFind

func ParallelFind[T any](items []T, f func(T) bool) *T

func RandomElement

func RandomElement[T any](elements []T) (element T)

func RandomSubset

func RandomSubset[T any](array []T, size int) []T

func Remove

func Remove[T any](items []T, condition func(T) bool) []T

func RemoveDuplicates

func RemoveDuplicates[T comparable](items []T) []T

func RemoveElement

func RemoveElement[T comparable](items []T, element T) []T

func RemoveIndex

func RemoveIndex[T any](items []T, index int) []T

func Reverse

func Reverse[T any](items []T) []T

func Shuffle

func Shuffle[T any](items []T)

func Sort

func Sort[T any](items []T, less func(T, T) bool)

func SortOrdered

func SortOrdered[T cmp.Ordered](items []T)

func Sum

func Sum[T Number](values []T) T

func Swap

func Swap[T any](items []T, i, j int)

func Unless

func Unless[T any](items []T, f func(T) bool) bool

Types

type Number

type Number interface {
	int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | float32 | float64 | complex64 | complex128
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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