arrayx

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All added in v0.0.13

func All[T any](vs []T, condition func(T) bool) bool

All returns true if the provided function returns true for every element in the array.

func Any added in v0.0.13

func Any[T any](vs []T, condition func(T) bool) bool

Any returns true if the provided function returns true for any element in the array.

func Append added in v0.0.14

func Append[T any](arr []T, items ...T) []T

func AppendArr added in v0.0.14

func AppendArr[T any](arr []T, items ...[]T) []T

func Clone

func Clone[T any](arr []T) []T

Clone returns a copy of the array.

func Contains

func Contains[T comparable](arr []T, item T) bool

Contains returns true if the array contains the item.

func ContainsAll added in v0.0.16

func ContainsAll[T comparable](arr []T, items ...T) bool

func ContainsAny added in v0.0.14

func ContainsAny[T comparable](arr []T, items ...T) bool

func EditEach added in v0.0.13

func EditEach[T any](arr []T, f func(index int, data T) T)

func Find added in v0.0.13

func Find[T any](vs []T, condition func(T) bool) (val T, ok bool)

Find returns the first element in the array that satisfies the provided testing function.

func FindIndex added in v0.0.13

func FindIndex[T any](vs []T, condition func(T) bool) (int, bool)

FindIndex returns the index of the first element in the array that satisfies the provided testing function.

func FindLast added in v0.0.13

func FindLast[T any](vs []T, condition func(T) bool) (val T, ok bool)

FindLast returns the last element in the array that satisfies the provided testing function.

func FindLastIndex added in v0.0.13

func FindLastIndex[T any](vs []T, condition func(T) bool) (int, bool)

FindLastIndex returns the index of the last element in the array that satisfies the provided testing function.

func First

func First[T any](l []T) (fst T, ok bool)

First returns the first element of an array.

func ForEach

func ForEach[T any](arr []T, f func(index int, data T))

ForEach executes a provided function once for each array element.

func ForEachRef added in v0.0.14

func ForEachRef[T any](arr []T, f func(index int, data *T))

func HasDuplicate

func HasDuplicate[T comparable](arr []T) bool

HasDuplicate returns true if the array has duplicate items.

func Last

func Last[T any](l []T) (last T, ok bool)

Last returns the last element of an array.

func Map

func Map[T any, K any](from []T, tx func(T) K) []K

Map returns a new array with the results of calling a provided function on every element in the calling array.

func NotEmpty

func NotEmpty[T any](a ...[]T) bool

func NotNil

func NotNil(a ...any) bool

func PreAppend added in v0.0.16

func PreAppend[T any](item T, slice []T) []T

func RemoveAt added in v0.0.14

func RemoveAt[T any](arr []T, i int) []T

func RemoveDuplicate

func RemoveDuplicate[T comparable](arr []T) []T

RemoveDuplicate returns a new array without duplicate items.

func Reverse

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

func SafeIndex added in v0.0.15

func SafeIndex[T any](s []T, i int, ifFailed T) T

func Shuffle

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

func Sum

func Sum[T constrains.Calculable](arr []T) T

func Where

func Where[T1 any](vs []T1, condition func(T1) bool) []T1

Where returns a new array with the results of calling a provided function on every element in the array.

Types

This section is empty.

Jump to

Keyboard shortcuts

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