maputils

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: May 27, 2022 License: MIT Imports: 0 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy[K comparable, V any](mapInstance map[K]V) map[K]V

Copy - takes a map with keys K and values V and returns a copy of the map.

func Drop

func Drop[K comparable, V any](mapInstance map[K]V, keys []K) map[K]V

Drop - takes a map with keys K and values V, and a slice of keys K, dropping all the key-value pairs that match the keys in the slice. Note: this function will modify the passed in map. To get a different object, use the Copy function to pass a copy to this function.

func Filter

func Filter[K comparable, V any](mapInstance map[K]V, function func(key K, value V) bool) map[K]V

Filter - takes a map with keys K and values V, and executes the passed in function for each key-value pair. If the filter function returns true, the key-value pair will be included in the output, otherwise it is filtered out.

func ForEach

func ForEach[K comparable, V any](mapInstance map[K]V, function func(key K, value V))

ForEach - given a map with keys K and values V, executes the passed in function for each key-value pair.

func Keys

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

Keys - takes a map with keys K and values V, returns a slice of type K of the map's keys. Note: Go maps do not preserve insertion order.

func Merge

func Merge[K comparable, V any](mapInstances ...map[K]V) map[K]V

Merge - takes an arbitrary number of map instances with keys K and values V and merges them into a single map. Note: merge works from left to right. If a key already exists in a previous map, its value is over-written.

func Values

func Values[K comparable, V any](mapInstance map[K]V) []V

Values - takes a map with keys K and values V, returns a slice of type V of the map's values. Note: Go maps do not preserve insertion order.

Types

This section is empty.

Jump to

Keyboard shortcuts

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