ads

package
v0.0.0-...-016edcc Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All[T any](a []T, f func(e T) bool) bool

func Chunk

func Chunk[T any](slice []T, chunkSize int) [][]T

func Contains

func Contains[T comparable](a []T, e T) bool

func ContainsAll

func ContainsAll[T comparable](a []T, e []T) bool

func ContainsAny

func ContainsAny[T comparable](a []T, e []T) bool

func Copy

func Copy[S ~[]E, E any](a S) S

func Dedup

func Dedup[T any, K comparable](as []T, id func(T) K) []T

func DedupAppend

func DedupAppend[T any, K comparable](as []T, id func(T) K, vs ...T) []T

func DedupAppendIdentity

func DedupAppendIdentity[T comparable](as []T, vs ...T) []T

func DedupAppender

func DedupAppender[T any, K comparable](as []T, id func(T) K, cap int) func([]T, T) []T

func DedupAppenderIdentity

func DedupAppenderIdentity[T comparable](as []T, cap int) func([]T, T) []T

func DedupIdentity

func DedupIdentity[T comparable](as []T) []T

func Filter

func Filter[S ~[]E, E any](a S, f func(E) bool) S

func Find

func Find[T any](a []T, f func(T) bool) (T, bool)

func FindIndex

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

func Grow

func Grow[S ~[]E, E any](slice S, newCap int) S

func GrowExtra

func GrowExtra[S ~[]E, E any](slice S, extraCap int) S

func Last

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

func LastP

func LastP[T any](a []T) *T

func Map

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

func MapE

func MapE[T, O any](a []T, f func(T) (O, error)) ([]O, error)

func MapFlat

func MapFlat[T comparable](a []T, f func(T) []T) []T

func MapFlatE

func MapFlatE[T comparable](a []T, f func(T) ([]T, error)) ([]T, error)

func Reduce

func Reduce[T any, O any](a []T, f func(O, T) O, initial O) O

func ReduceE

func ReduceE[T any, O any](a []T, f func(O, T) (O, error), initial O) (O, error)

func Remove

func Remove[T comparable](slice []T, e T) []T

func RemoveIndex

func RemoveIndex[T any](slice []T, s int) []T

func Reverse

func Reverse[S ~[]E, E any](a S) S

func Some

func Some[T any](a []T, f func(e T) bool) bool

func Sort

func Sort[T any](a []T, comparers ...Comparer[T])

Sort sorts by passing a copy of the data around

func SortFunc

func SortFunc[S ~[]E, E any](x S, less func(a, b E) bool)

func SortP

func SortP[T any](a []T, comparers ...Comparer[*T])

SortP sorts by passing a pointer of the data around

Types

type Comparer

type Comparer[T any] func(i, j T) int

type Group

type Group[T any, K comparable] struct {
	Key   K
	Items []T
}

func OrderedGroupBy

func OrderedGroupBy[T any, K comparable](a []T, keyer func(T) K, less func(i, j T) bool) []Group[T, K]

Jump to

Keyboard shortcuts

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