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: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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