dataUtils

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2025 License: BSD-2-Clause Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapContains

func MapContains[K comparable, V any](data map[K]V, key K) bool

MapContains checks if the provided map contains the specified key.

func MapKeys

func MapKeys[K comparable, V any](data map[K]V) []K

MapKeys returns a slice of keys from the provided map.

func MapOrderedIterator

func MapOrderedIterator[K Constraints, V any](data map[K]V) func(yield func(K, V) bool)

MapOrderedIterator returns a function that iterates over the provided map in a sorted order.

func MapPipeline added in v1.1.5

func MapPipeline[K comparable, V, T any](data map[K]V, predicate func(K, V) T) map[K]T

func MapToSlice added in v1.1.4

func MapToSlice[K comparable, V, T any](data map[K]V, predicate func(K, V) T) []T

func MapValueContains

func MapValueContains[K, V comparable](data map[K]V, value V) bool

MapValueContains checks if the provided map contains the specified value.

func MapValues

func MapValues[K comparable, V any](data map[K]V) []V

MapValues returns a slice of values from the provided map.

func SliceDistinct

func SliceDistinct[T comparable](list []T) []T

SliceDistinct returns a new slice with unique elements from the provided slice.

func SliceFilter

func SliceFilter[T any](slice []T, predicate func(*T) bool) []T

SliceFilter returns a new slice with elements that satisfy the provided predicate function.

func SliceForeach

func SliceForeach[T any](slice *[]T, predicate func(*T))

SliceForeach applies the provided function to each element in the provided slice.

func SliceOrderAsk

func SliceOrderAsk[T Constraints](slice *[]T)

SliceOrderAsk sorts the provided slice in ascending order.

func SliceOrderDesc

func SliceOrderDesc[T Constraints](slice *[]T)

SliceOrderDesc sorts the provided slice in descending order.

func SlicePipeline added in v1.1.4

func SlicePipeline[T, R any](slice []T, predicate func(*T) R) []R

func SliceToMap

func SliceToMap[T any, K comparable, V any](slice *[]T, predicate func(*T) (K, V)) map[K]V

SliceToMap converts the provided slice to a map using the provided predicate function.

Types

type Constraints

type Constraints interface {
	int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | uintptr | float32 | float64 | ~string
}

Constraints is a type constraint that defines the types that can be used with the SliceOrderAsk and SliceOrderDesc functions.

Jump to

Keyboard shortcuts

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