sliceutils

package
v0.0.0-...-b6fc690 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains[T comparable](data []T, v T) bool

func ElementsMatch

func ElementsMatch(listA, listB interface{}) (ok bool, err error)

func ElementsMatchImplicit

func ElementsMatchImplicit(listA, listB interface{}) bool

func EqualValues

func EqualValues[S ~[]E, E cmp.Ordered](a, b S) bool

EqualValues checks if two slices have equal values, regardless of ordering. This does not recurse into nested slices or structs.

func Filter

func Filter[T any](data []T, f func(T) bool) []T

func GetInt

func GetInt(slice []int, index int) (int, bool)

func GetString

func GetString(slice []string, index int) (string, bool)

func InsertStringAt

func InsertStringAt(data []string, i int, v string) []string

InsertAt inserts v into data at position i

func IntRangeUncapped

func IntRangeUncapped(in []int, start, end int) []int

func ObjectsAreEqual

func ObjectsAreEqual(expected, actual interface{}) bool

ObjectsAreEqual determines if two objects are considered equal.

This function does no assertion of any kind.

func Pop

func Pop[T any](data []T) (T, []T, error)

func RemoveFromStrings

func RemoveFromStrings(slice []string, indexes ...int) []string

func ToLookupMap

func ToLookupMap[T string | int | strfmt.UUID](data []T) map[T]struct{}

func ToLookupMapByKey

func ToLookupMapByKey[T any, K string | int | strfmt.UUID](data []T, keyCb func(T) K) map[K]T

func Unique

func Unique[T comparable](data []T) []T

func UniqueByProperty

func UniqueByProperty[T comparable](data []T, uniq func(T) any) []T

Types

This section is empty.

Jump to

Keyboard shortcuts

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