structs

package
v0.5.10 Latest Latest
Warning

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

Go to latest
Published: May 5, 2024 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package structs provides basic operations with maps and slices

Package structs provides basic operations with maps and slices

Package structs provides basic operations with maps and slices

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterMap

func FilterMap[K comparable, V any](collection map[K]V, filter func(V) bool) map[K]V

FilterMap filters the map.

func FilterSlice

func FilterSlice[V any](collection []V, filter func(V) bool) []V

FilterSlice is a filter function.

func ForEach

func ForEach[T any](collection []T, f func(T))

ForEach iterator function.

func If added in v0.5.10

func If[V any](condition bool, then V, els V) V

func IfVal added in v0.5.10

func IfVal[V any](condition bool, then *V, els *V) V

func Keys

func Keys[K comparable, V any](in map[K]V) []K

Keys returns a slice with map keys.

func Map

func Map[T any, R any](collection []T, f func(T) R) []R

Map is a map function.

func MapWithError

func MapWithError[T any, R any](collection []T, f func(T) (R, error)) ([]R, error)

MapWithError is a map function with error returns.

func Ref

func Ref[V comparable](v V) *V

Ref returns reference to value.

func SliceToMap

func SliceToMap[K comparable, V any](collection []V, key func(V) K) map[K]V

SliceToMap converts slice of structs to map.

func SliceToMapOfStruct

func SliceToMapOfStruct[K comparable, V any](collection []V, key func(V) K) map[K]struct{}

SliceToMapOfStruct converts slice of structs to map of struct.

func Val

func Val[V comparable](v *V) V

Val returns value of reference.

Types

This section is empty.

Jump to

Keyboard shortcuts

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