Documentation
¶
Index ¶
- Variables
- func At[T any](arr []T, index int) (result T)
- func Equal[T comparable](firstArr, secondArr []T) bool
- func EqualRef[T comparable](firstArr, secondArr []*T) bool
- func Every[T any](arr []T, test func(T) bool) bool
- func Fill[T any](arr []T, value T, startEnd ...int) []T
- func FillWithExtensible[T any](arr []T, value T, startEnd ...int) []T
- func Filter[T any](arr []T, fn func(T) bool) []T
- func Find[T any](arr []T, test func(T) bool) T
- func FindIndex[T any](arr []T, test func(T) bool) int
- func FindNth[T any](arr []T, test func(T) bool, findNth int) T
- func FindNthIndex[T any](arr []T, test func(T) bool, findNth int, force bool) int
- func FindNthWithErr[T any](arr []T, test func(T) bool, findNth int) (T, error)
- func FindWithErr[T any](arr []T, test func(T) bool) (T, error)
- func Flatten[T any](input interface{}) []T
- func FlattenAll[T any](input interface{}) []T
- func GroupBy[T any, U comparable](arr []T, getKey func(T) U) (result map[U][]T)
- func GroupByAndReshape[T any, U comparable, V any](arr []T, getKey func(T) U, reshape func(T) V) (result map[U][]V)
- func Includes[T comparable](slice []T, searchElement T, fromIndex ...int) bool
- func IndexOf[T comparable](slice []T, searchElement T, fromIndex ...int) int
- func Init[T any](length int, setValue func(int) T) []T
- func InitConst[T any](length int, value T) []T
- func Insert[T any](arr []T, index int, value T) []T
- func InsertSafe[T any](arr []T, index int, value T) []T
- func InsertWithErr[T any](arr []T, index int, value T) ([]T, error)
- func Keys[T any](arr []T) []int
- func Map[T any, U any](arr []T, fn func(T) U) (result []U)
- func Paging[T any](arr []T, page, pageSize int) []T
- func Pop[T any](slice *[]T) T
- func PopWithErr[T any](slice *[]T) (T, error)
- func Reduce[T any, U any](arr []T, fn func(U, T) U, initial U) (result U)
- func Reverse[T any](slice []T)
- func Rotate[T any](arr []T, times int) []T
- func RotateByIndex[T any](arr []T, index int) []T
- func RotateByIndexSafe[T any](arr []T, index int) []T
- func Shift[T any](slice *[]T) T
- func ShiftWithErr[T any](slice *[]T) (T, error)
- func Some[T any](slice []T, callbackFn func(T) bool) bool
- func Splice[T any](slice *[]T, start int, deleteCount int, items ...T) []T
- func Unique[T comparable](arr []T) []T
- func ValueEqual[T comparable](firstArr, secondArr []T) bool
- type Entry
- type Iterator
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotFound = errors.New("not found")
View Source
var ErrOutOfRange = errors.New("out of range")
Functions ¶
func Equal ¶
func Equal[T comparable](firstArr, secondArr []T) bool
func EqualRef ¶
func EqualRef[T comparable](firstArr, secondArr []*T) bool
func FillWithExtensible ¶
FillWithExtensible 填充数组中的元素并在需要时扩展数组长度
func Filter ¶
Filter function creates a new array with all elements that pass the test implemented by the provided function.
func FindNthIndex ¶
func FindNthWithErr ¶
func FindWithErr ¶
func FlattenAll ¶
func FlattenAll[T any](input interface{}) []T
func GroupBy ¶
func GroupBy[T any, U comparable](arr []T, getKey func(T) U) (result map[U][]T)
func GroupByAndReshape ¶
func GroupByAndReshape[T any, U comparable, V any](arr []T, getKey func(T) U, reshape func(T) V) (result map[U][]V)
func Includes ¶
func Includes[T comparable](slice []T, searchElement T, fromIndex ...int) bool
func IndexOf ¶
func IndexOf[T comparable](slice []T, searchElement T, fromIndex ...int) int
indexOf 函数在切片中查找元素的索引,支持从指定索引开始查找
func InsertSafe ¶
InsertSafe function inserts an element at the given index or at the nearest valid position
func InsertWithErr ¶
func PopWithErr ¶
func RotateByIndex ¶
func RotateByIndexSafe ¶
func ShiftWithErr ¶
func Unique ¶
func Unique[T comparable](arr []T) []T
func ValueEqual ¶
func ValueEqual[T comparable](firstArr, secondArr []T) bool
Types ¶
type Iterator ¶
type Iterator[T any] struct { // contains filtered or unexported fields }
Iterator represents a slice iterator.
func NewIterator ¶
NewIterator creates a new iterator for a slice.
Click to show internal directories.
Click to hide internal directories.