sliceutil

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2024 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BinarySearch added in v0.11.0

func BinarySearch[T any](slice []T, val T, compare func(T, T) int) int

BinarySearch searches for a value in a sorted slice and returns the index of the value. If the value is not found, it returns -1

func SliceContains

func SliceContains[T comparable](arr []T, val T) bool

func SliceCopy

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

func SliceMapper

func SliceMapper[T any, V any](items []T, mpr func(T) V) []V

func SliceMapperError

func SliceMapperError[T any, V any](items []T, mpr func(T) (V, error)) (slice []V, err error)

func SliceMapperFilter

func SliceMapperFilter[T any, V any](items []T, mpr func(T) (bool, V)) []V

func SliceUnique

func SliceUnique[T any, C comparable](arr []T, eq func(T) C) []T

Types

This section is empty.

Jump to

Keyboard shortcuts

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