collections

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AscOrder

func AscOrder[K constraints.Ordered](v1, v2 K) bool

AscOrder is a comparison function for sorting in ascending order

func CreateDictFromSlice

func CreateDictFromSlice[K comparable, X any, Y any](input []X, keyFunc func(*X) K, valueFunc func(*X) Y) map[K]Y

CreateDictFromSlice is a generic function for creating a hash table from a flat list

func CreateSliceFromDict

func CreateSliceFromDict[K comparable, X any, Y any](input map[K]X, f func(K, X) Y) []Y

CreateSliceFromDict creates a slice from a hash table

func DescOrder

func DescOrder[K constraints.Ordered](v1, v2 K) bool

DescOrder is a comparison function for sorting in descending order

func ForEachSlice

func ForEachSlice[X any](input []X, f func(int, *X) error) error

ForEachSlice is a generic function for modifying elements of a slice

func GetSymmetricallyDifferentKeys

func GetSymmetricallyDifferentKeys[K comparable, X any](a, b map[K]X) ([]K, []K)

GetSymmetricallyDifferentKeys returns the symmetric difference of keys of hash tables Unique keys of each hash table are returned separately

func GroupByToDict

func GroupByToDict[K comparable, X any, Y any](input []X, keyFunc func(*X) K, valueFunc func(*X) Y) map[K][]Y

GroupByToDict is a generic function for grouping data into a hash table

func MapAndFilterSliceWithIndex

func MapAndFilterSliceWithIndex[X any, Y any](input []X, f func(int, X) Y, filter func(int, X) bool) []Y

MapAndFilterSliceWithIndex is a generic function for filtering and transforming elements of a slice

func MapSlice

func MapSlice[X any, Y any](input []X, f func(X) Y) []Y

MapSlice is a generic function that takes a slice of elements of type X and transforms it into a slice of elements of type Y by applying the function f to each element

func MapSliceWithIndex

func MapSliceWithIndex[X any, Y any](input []X, f func(int, X) Y) []Y

MapSliceWithIndex is a generic function that takes a slice of elements of type X and transforms it into a slice of elements of type Y by applying the function f to each element, including the index

func SortSlice

func SortSlice[K constraints.Ordered](slice []K) []K

SortSlice is a generic function for sorting slices in ascending order

func SortSliceWithCmpFunc

func SortSliceWithCmpFunc[K any](slice []K, comparisonFunc func(k1, k2 K) bool) []K

SortSliceWithCmpFunc is a generic function for sorting lists with customizable comparison

func SplitIntoBatches added in v0.0.3

func SplitIntoBatches[X any](input []X, batchSize int) [][]X

SplitIntoBatches splits a slice into batches of a given size

Types

This section is empty.

Jump to

Keyboard shortcuts

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