slice

package
v0.2.12 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 2 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Count

func Count[T constraints.Ordered](s []T, target T) int

func CountIf

func CountIf[T any](s []T, checkFn func(T) bool) int

func MaxValueAndIndex

func MaxValueAndIndex[T constraints.Ordered](s []T) (max T, idx int)

MaxValueAndIndex return max value and the index of first max

func OrderedSlice

func OrderedSlice[T constraints.Ordered](s []T)

OrderedSlice sorts the slice s in ascending order. The elements of s must be ordered using the < operator.

func PushFront

func PushFront[T any](s []T, item T) []T

func RemoveAt

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

func RemoveHead

func RemoveHead[T any](items []T, k int) []T

func RemoveTail

func RemoveTail[T any](items []T, k int) []T

func Reverse

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

func RotateLeft

func RotateLeft[T any](items []T, k int)

func RotateRight

func RotateRight[T any](items []T, k int)

func SliceFn

func SliceFn[T any](s []T, cmp func(T, T) bool)

SliceFn sorts the slice s according to the function cmp. Usage:

var s []*Person
...
sort.SliceFn(s, func(p1, p2 *Person) bool { return p1.Name < p2.Name })

func SortAscUniq added in v0.2.11

func SortAscUniq[T constraints.Ordered](s []T) []T

func SortDescUniq added in v0.2.11

func SortDescUniq[T constraints.Ordered](s []T) []T

func UniqSorted added in v0.2.11

func UniqSorted[T constraints.Ordered](s []T) []T

Types

This section is empty.

Jump to

Keyboard shortcuts

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