mapz

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: MIT Imports: 1 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clear

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

Clear will delete all elements from a map Warning mutates map

func Clone

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

Clone will copy all keys and values of a map in to a new one

func Copy

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

Copy will copy all entries in src into det Warning mutates map

func Delete

func Delete[K comparable, V any](m map[K]V, del func(K, V) bool)

Delete will remove all entries from a map where the del function returns true Warning mutates map, , use Filter or Reject for immutable version

func DeleteKeys

func DeleteKeys[K comparable, V any](m map[K]V, needles ...K)

DeleteKeys will remove all instances where the needles matches a key in the map Warning mutates map, use Filter or Reject for immutable version

func DeleteValues

func DeleteValues[K comparable, V comparable](m map[K]V, needles ...V)

DeleteValues will remove all instances where the needle matches a value in the map Warning mutates map, use Filter or Reject for immutable version

func Equal

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

Equal returns true if all key are present in both maps and map to the same value

func EqualBy

func EqualBy[K comparable, V1, V2 any](m1 map[K]V1, m2 map[K]V2, eq func(V1, V2) bool) bool

EqualBy returns true if all key are present in both maps and map to the same value, determined by the "eq" func

func Filter

func Filter[K comparable, V any](m map[K]V, pick func(key K, val V) bool) map[K]V

func FilterByKeys

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

func FilterByValues

func FilterByValues[K comparable, V comparable](m map[K]V, values []V) map[K]V

func FromEntries

func FromEntries[K comparable, V any](slice []Entry[K, V]) map[K]V

func Invert

func Invert[K, V comparable](m map[K]V) map[V]K

func Keys

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

Keys returns all keys in a map in a none deterministic order

func Merge

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

Merge multiple maps from left to right into a new map.

func Reject

func Reject[K comparable, V any](m map[K]V, omit func(key K, val V) bool) map[K]V

func RejectByKeys

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

func RejectByValues

func RejectByValues[K comparable, V comparable](m map[K]V, values []V) map[K]V

func Remap

func Remap[K comparable, V any, K2 comparable, V2 any](in map[K]V, mapper func(K, V) (K2, V2)) map[K2]V2

Remap manipulates a map keys and values and transforms it to a map of another types.

func RemapKeys

func RemapKeys[K comparable, V any, K2 comparable](in map[K]V, mapper func(K, V) K2) map[K2]V

RemapKeys manipulates a map keys and transforms it to a map of another types.

func RemapValues

func RemapValues[K comparable, V any, V2 any](in map[K]V, mapper func(K, V) V2) map[K]V2

RemapValues manipulates a map keys and transforms it to a map of another types.

func Slice

func Slice[E any, K comparable, V any](m map[K]V, zip func(K, V) E) []E

func ValueOr

func ValueOr[K comparable, V any](m map[K]V, key K, fallback V) V

func Values

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

Values returns all values in a map in a none deterministic order

Types

type Entry

type Entry[K comparable, V any] struct {
	Key   K
	Value V
}

func Entries

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

Jump to

Keyboard shortcuts

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