mapx

package
v2.0.0-beta3 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2022 License: BSD-2-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeIfAbsent

func ComputeIfAbsent[K comparable, V any](m map[K]V, k K, makeValue func(key K) V) V

ComputeIfAbsent compute the value, add key-value to map, if key not exists; then return the current value.

func ContainsAnyKey

func ContainsAnyKey[K comparable, V any](m map[K]V, keys ...K) bool

ContainsAnyKey return whether map contains any one of the keys

func ContainsKey

func ContainsKey[K comparable, V any](m map[K]V, k K) bool

ContainsKey return whether map contains the key

func ConvertValues

func ConvertValues[K comparable, V any, U any](m map[K]V, convert func(key V) U) map[K]U

ConvertValues create new map from original map, with values generated by original values and convert function.

func Copy

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

Copy shallow copy a map

func Equals

func Equals[K comparable, V comparable](m1 map[K]V, m2 map[K]V) bool

Equals compare two maps, return true if hase same keys and values

func FromKeys

func FromKeys[K comparable, V any](keys []K, makeValue func(key K) V) map[K]V

FromKeys create map from keys

func FromValues

func FromValues[K comparable, V any](values []V, extractKey func(v V) K) map[K]V

FromValues create map from values

func Get

func Get[K comparable, V any](m map[K]V, k K) gox.Optional[V]

Get return map value of specified key, return default value if key not exists

func Keys

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

Keys return map keys in a new Slice

func PutAll

func PutAll[K comparable, V any](m map[K]V, entries map[K]V)

PutAll add all key-values entries into the map. If key already exists, will be set to new value.

func PutIfAbsent

func PutIfAbsent[K comparable, V any](m map[K]V, k K, v V) V

PutIfAbsent add key-value to map, if key not exists; and return the current value.

func Values

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

Values return map value in a new slice

Types

This section is empty.

Jump to

Keyboard shortcuts

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