slices

package
v6.8.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BreakIntoGroups

func BreakIntoGroups[T any](collection []T, groupSize int) [][]T

BreakIntoGroups breaks a slice into groups of a given size.

func ConvertSlice added in v6.8.0

func ConvertSlice[T any, K any](a []T, convertFunc func(T) K) []K

ConvertSlice converts all the values in slice 'a' from type T to type K using a converter function.

converted := slices.ConvertSlice[graphql.String, string](someStruct.GraphQLStrings, func(input graphql.String) string {
  return string(input)
})

func Filter added in v6.8.0

func Filter[T any](a []T, test func(T) bool) []T

Filter applies the function 'test' to all values in a slice and returns a new slice for all values where 'test' returned true.

func IsInSlice

func IsInSlice[T comparable](item T, slice []T) bool

IsInSlice checks if an item is in a slice. This function will work on anything that implements the comparable interface.

Types

This section is empty.

Jump to

Keyboard shortcuts

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