Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetOrDefault ¶
func GetOrDefault[K comparable, V any](m map[K]V, key K, defaultValue V) V
GetOrDefault retrieves the value for the key in the map if it exists. If it doesn't exist, then returns the default value.
func MapSlice ¶
MapSlice converts a slice of type K into a slice of type V using the provided mapper function.
func MergeMaps ¶
func MergeMaps[K comparable, V any](maps ...map[K]V) map[K]V
MergeMaps merges multiple maps into a new one. Duplicate keys will take the last map's value.
func WithNewKeys ¶
func WithNewKeys[K comparable, V any](base map[K]V, keyMapper map[K]K) map[K]V
WithNewKeys re-maps every key in a map as dictated by the mapper. If the key does not have an entry in the mapper, it is left untouched.
Types ¶
type Set ¶
type Set[K comparable] map[K]any
Set is a map with a comparable K key and no meaningful value.
func NewSet ¶
func NewSet[K comparable](keys ...K) Set[K]
NewSet creates a new Set with the keys provided.
Click to show internal directories.
Click to hide internal directories.