maps

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: MIT Imports: 2 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Batch

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

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 Default

func Default[K comparable, V any](v, def Map[K, V]) 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 Of

func Of[K comparable, V any](a ...any) Map[K, V]

func (Map[K, V]) Equals

func (m Map[K, V]) Equals(t Map[K, V], eq func(left, right V) bool) bool

func (Map[K, V]) Get

func (m Map[K, V]) Get(k K) *V

Get should be used cautiously

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]) Has

func (m Map[K, V]) Has(k K) bool

func (Map[K, V]) Keys

func (m Map[K, V]) Keys() []K

func (Map[K, V]) Length

func (m Map[K, V]) Length() int

func (Map[K, V]) Merge

func (m Map[K, V]) Merge(merge func(o, n V) (V, error), a ...Map[K, V]) (Map[K, V], error)

func (Map[K, V]) Put

func (m Map[K, V]) Put(k K, v V) Map[K, V]

func (Map[K, V]) PutAll

func (m Map[K, V]) PutAll(a ...Map[K, V]) Map[K, V]

func (Map[K, V]) PutAllWith

func (m Map[K, V]) PutAllWith(f func(o, n V) V, a ...Map[K, V]) Map[K, V]

func (Map[K, V]) PutIfAbsent

func (m Map[K, V]) PutIfAbsent(k K, f func(k K) V) V

func (Map[K, V]) String

func (m Map[K, V]) String(ks func(k K) string, vs func(v V) string, kvsep, sep string) string

func (Map[K, V]) Values

func (m Map[K, V]) Values() []V

type Set

type Set[K comparable] interface {
	Has(k K) bool
}

func SetOf

func SetOf[K comparable](a ...K) Set[K]

Jump to

Keyboard shortcuts

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