Documentation
¶
Overview ¶
Package maps provides map-based data structures and utilities.
This file contains a Set implementation built on top of the Map type, providing a simple set interface for comparable key types.
Index ¶
- func Batch[K comparable, V any, T any](m Map[K, V], n int, fn func(Map[K, V]) ([]T, error)) ([]T, error)
- func Composite[K comparable, V, O any](m Map[K, V], fn func(k K, v V) O) lists.List[O]
- func FromFilter[K comparable, T any](arr []T, key func(T) K, filter func(T) bool) (Map[K, T], Map[K, T])
- func Getter[K comparable, V any](field K) func(Map[K, V]) V
- func Visit[K comparable, V interface{}, P interface{}](m map[K]V, parent *P, tracer func(parent *P, key K) *P, ...)
- type Map
- func (m Map[K, V]) Equals(t Map[K, V], eq func(left, right V) bool) bool
- func (m Map[K, V]) Get(k K) *V
- func (m Map[K, V]) GetOrDefault(k K, def V) *V
- func (m Map[K, V]) Has(k K) bool
- func (m Map[K, V]) Keys() []K
- func (m Map[K, V]) Length() int
- func (m Map[K, V]) Merge(merge func(o, n V) (V, error), a ...Map[K, V]) (Map[K, V], error)
- func (m Map[K, V]) Put(k K, v V) Map[K, V]
- func (m Map[K, V]) PutAll(a ...Map[K, V]) Map[K, V]
- func (m Map[K, V]) PutAllWith(f func(o, n V) V, a ...Map[K, V]) Map[K, V]
- func (m Map[K, V]) PutIfAbsent(k K, f func(k K) V) V
- func (m Map[K, V]) String(ks func(k K) string, vs func(v V) string, kvsep, sep string) string
- func (m Map[K, V]) Values() []V
- type Set
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Composite ¶
func Composite[K comparable, V, O any](m Map[K, V], fn func(k K, v V) O) lists.List[O]
func FromFilter ¶
func FromFilter[K comparable, T any](arr []T, key func(T) K, filter func(T) bool) (Map[K, T], Map[K, T])
func Getter ¶
func Getter[K comparable, V any](field K) func(Map[K, V]) V
func Visit ¶
func Visit[K comparable, V interface{}, P interface{}](m map[K]V, parent *P, tracer func(parent *P, key K) *P, drill func(value V) (map[K]V, bool), action func(parent *P, key K, value V))
Types ¶
type Map ¶
type Map[K comparable, V interface{}] map[K]V
func From ¶
func From[K comparable, T any](arr []T, key func(T) K) Map[K, T]
func FromFn ¶
func FromFn[K comparable, T, O any](arr []T, key func(T) K, val func(T) O) Map[K, O]
func (Map[K, V]) GetOrDefault ¶
func (m Map[K, V]) GetOrDefault(k K, def V) *V
GetOrDefault should be used cautiously
func (Map[K, V]) PutAllWith ¶
func (Map[K, V]) PutIfAbsent ¶
func (m Map[K, V]) PutIfAbsent(k K, f func(k K) V) V
type Set ¶
type Set[K comparable] interface { Has(k K) bool }
func SetOf ¶
func SetOf[K comparable](a ...K) Set[K]
Click to show internal directories.
Click to hide internal directories.