mapx

package
v0.1.22 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: MIT Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterFunc

func FilterFunc[K comparable, V any](oldMap map[K]V, cmp func(key K, val V) (ok bool)) (newMap map[K]V)

FilterFunc filters a map by a custom function, the function should return a boolean indicating if the key should be included.

func FilterWithPrefix

func FilterWithPrefix[V any](oldMap map[string]V, prefix string) (newMap map[string]V)

FilterWithPrefix filters a map by a prefix, only keys with the prefix will be included.

func ProjectFunc

func ProjectFunc[K comparable, V any](oldMap map[K]V, proj func(oldKey K, val V) (newKey K, ok bool)) (newMap map[K]V)

ProjectFunc projects a map by a custom function, the function should return the new key and a boolean indicating if the key should be included.

func ProjectWithPrefix

func ProjectWithPrefix[V any](oldMap map[string]V, prefix string) (newMap map[string]V)

ProjectWithPrefix projects a map by a prefix, only keys with the prefix will be included, and the prefix will be removed from the keys.

func Value added in v0.1.1

func Value[K comparable, V any](m map[K]V, key K, defVal ...V) V

Value returns the value of a key in a map, if the key does not exist, the default value will be returned.

Types

This section is empty.

Jump to

Keyboard shortcuts

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