dict

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package dict is a package of generic-type functions for map.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

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

Copy creates a copy of the map.

func Entries

func Entries[K comparable, V any](m map[K]V) []gust.DictEntry[K, V]

Entries returns the entries of map.

func Every

func Every[K comparable, V any](m map[K]V, fn func(k K, v V) bool) bool

Every tests whether all entries in the map pass the test implemented by the provided function. NOTE:

Calling this method on an empty map will return true for any condition!

func Filter

func Filter[K comparable, V any](m map[K]V, fn func(K, V) bool) map[K]V

Filter creates a new map with all elements that pass the test implemented by the provided function.

func FilterMap

func FilterMap[K comparable, V any, K2 comparable, V2 any](m map[K]V, fn func(K, V) gust.Option[gust.DictEntry[K2, V2]]) map[K2]V2

FilterMap returns a filtered and mapped map of new entries.

func FilterMapKey

func FilterMapKey[K comparable, V any, K2 comparable](m map[K]V, fn func(K, V) gust.Option[gust.DictEntry[K2, V]]) map[K2]V

FilterMapKey returns a filtered and mapped map of new entries.

func FilterMapValue

func FilterMapValue[K comparable, V any, V2 any](m map[K]V, fn func(K, V) gust.Option[gust.DictEntry[K, V2]]) map[K]V2

FilterMapValue returns a filtered and mapped map of new entries.

func Find

func Find[K comparable, V any](m map[K]V, fn func(K, V) bool) gust.Option[gust.DictEntry[K, V]]

Find returns an entry in the provided map that satisfies the test function.

func Get added in v1.5.0

func Get[K comparable, V any](m map[K]V, k K) gust.Option[V]

Get returns the gust.Option[V] of the entry for the provided key.

func Keys

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

Keys returns the keys of map.

func Map

func Map[K comparable, V any, K2 comparable, V2 any](m map[K]V, mapping func(K, V) gust.DictEntry[K2, V2]) map[K2]V2

Map creates a new map populated with the results of calling a provided function on every entry in the calling map.

func MapCurry

func MapCurry[K comparable, V any, K2 comparable, V2 any](m map[K]V, keyMapping func(K) K2) func(valueMapping func(V) V2) map[K2]V2

MapCurry creates a new map populated with the results of calling a provided function on every entry in the calling map.

func MapKey

func MapKey[K comparable, V any, K2 comparable](m map[K]V, mapping func(K, V) K2) map[K2]V

MapKey creates a new map populated with the results of calling a provided function on every entry in the calling map.

func MapKeyAlone

func MapKeyAlone[K comparable, V any, K2 comparable](m map[K]V, mapping func(K) K2) map[K2]V

MapKeyAlone creates a new map populated with the results of calling a provided function on every entry in the calling map.

func MapValue

func MapValue[K comparable, V any, V2 any](m map[K]V, mapping func(K, V) V2) map[K]V2

MapValue creates a new map populated with the results of calling a provided function on every entry in the calling map.

func MapValueAlone

func MapValueAlone[K comparable, V any, V2 any](m map[K]V, mapping func(V) V2) map[K]V2

MapValueAlone creates a new map populated with the results of calling a provided function on every entry in the calling map.

func Some

func Some[K comparable, V any](m map[K]V, fn func(K, V) bool) bool

Some tests whether at least one entry in the map passes the test implemented by the provided function. NOTE:

Calling this method on an empty map returns false for any condition!

func Values

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

Values returns the values of map.

func Vec added in v1.5.0

func Vec[K comparable, V any, T any](m map[K]V, set func(K, V) T) []T

Vec generates an orderless slice through the set function.

Types

This section is empty.

Jump to

Keyboard shortcuts

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