xgmap

package
v0.0.0-...-241b93c Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2023 License: MIT Imports: 1 Imported by: 0

README

xgmap (generic map)

Dependencies

  • xgeneric/xsugar
  • xgeneric/xtuple

Documents

Types
  • None
Variables
  • None
Constants
  • None
Functions
  • func Keys[K comparable, V any](m map[K]V) []K
  • func Values[K comparable, V any](m map[K]V) []V
  • func KeyValues[K comparable, V any](m map[K]V) []xtuple.Tuple[K, V]
  • func FromKeys[K comparable, V any](slice []K, f func(int, K) V) map[K]V
  • func FromValues[K comparable, V any](slice []V, f func(int, V) K) map[K]V
  • func FromKeyValues[K comparable, V any](slice []xtuple.Tuple[K, V]) map[K]V
  • func Foreach[K comparable, V any](m map[K]V, f func(K, V))
  • func Map[K1, K2 comparable, V1, V2 any](m map[K1]V1, f func(K1, V1) (K2, V2)) map[K2]V2
  • func Expand[K1, K2 comparable, V1, V2 any](m map[K1]V1, f func(K1, V1) []xtuple.Tuple[K2, V2]) map[K2]V2
  • func Reduce[K comparable, V, U any](m map[K]V, initial U, f func(U, K, V) U) U
  • func Filter[M ~map[K]V, K comparable, V any](m M, f func(K, V) bool) M
  • func Any[K comparable, V any](m map[K]V, f func(K, V) bool) bool
  • func All[K comparable, V any](m map[K]V, f func(K, V) bool) bool
  • func Equal[M ~map[K]V, K, V comparable](m1, m2 M) bool
  • func EqualWith[M1 ~map[K]V1, M2 ~map[K]V2, K comparable, V1, V2 any](m1 M1, m2 M2, equaller func(V1, V2) bool) bool
  • func Clone[M ~map[K]V, K comparable, V any](m M) M
  • func CopyTo[K comparable, V any](dst, src map[K]V)
  • func Clear[M ~map[K]V, K comparable, V any](m M)
Methods
  • None

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All[K comparable, V any](m map[K]V, f func(K, V) bool) bool

All checks whether key-value pairs from given map that all satisfied given predicate function.

func Any

func Any[K comparable, V any](m map[K]V, f func(K, V) bool) bool

Any checks whether given map contains a key-value pair that satisfied given predicate function.

func Clear

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

Clear removes all entries from given map, leaving it empty.

func Clone

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

Clone returns a copy of given map, and the elements are copied using assignment.

func CopyTo

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

CopyTo copies all key-value pairs in src to dst.

func Equal

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

Equal reports whether two maps contain the same key/value pairs. Values are compared using `==`.

func EqualWith

func EqualWith[M1 ~map[K]V1, M2 ~map[K]V2, K comparable, V1, V2 any](m1 M1, m2 M2, equaller func(V1, V2) bool) bool

EqualWith is like Equal, but compares values using given equaller.

func Expand

func Expand[K1, K2 comparable, V1, V2 any](m map[K1]V1, f func(K1, V1) []xtuple.Tuple[K2, V2]) map[K2]V2

Expand maps and expands given map to another map using expand function.

func Filter

func Filter[M ~map[K]V, K comparable, V any](m M, f func(K, V) bool) M

Filter filters given map and returns a new map using given predicate function.

func Foreach

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

Foreach invokes given function for each key-value of given map.

func FromKeyValues

func FromKeyValues[K comparable, V any](slice []xtuple.Tuple[K, V]) map[K]V

FromKeyValues generates a map, its keys and values are from given kv-tuple slice.

func FromKeys

func FromKeys[K comparable, V any](slice []K, f func(int, K) V) map[K]V

FromKeys generates a map, its keys are from given slice, values are generated by given mapper function.

func FromValues

func FromValues[K comparable, V any](slice []V, f func(int, V) K) map[K]V

FromValues generates a map, its values are from given slice, keys are generated by given mapper function.

func KeyValues

func KeyValues[K comparable, V any](m map[K]V) []xtuple.Tuple[K, V]

KeyValues returns a key-value tuple slice of given map. Note that returned slice has no order.

func Keys

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

Keys returns a key slice of given map. Note that returned slice has no order.

func Map

func Map[K1, K2 comparable, V1, V2 any](m map[K1]V1, f func(K1, V1) (K2, V2)) map[K2]V2

Map maps given map to another map using mapper function.

func Reduce

func Reduce[K comparable, V, U any](m map[K]V, initial U, f func(U, K, V) U) U

Reduce reduces given map to a single value using initial value and left reducer function.

func Values

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

Values returns a value slice of given map. Note that returned slice has no order.

Types

This section is empty.

Jump to

Keyboard shortcuts

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