maps

package
v0.0.0-...-27647ab Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: BSD-3-Clause Imports: 2 Imported by: 3

Documentation

Overview

See also containers/mapbuilder.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clone

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

func ComputeDefault

func ComputeDefault[K comparable, V any](m map[K]V, k K, d func() V) V

func Contains

func Contains[K comparable, V any](m map[K]V, k K) bool

func FilterKeys

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

func FilterValues

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

func Get

func Get[K comparable, V any](m map[K]V, k 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

func Make

func Make[K comparable, V any]() map[K]V

func MapKeys

func MapKeys[KF, KT comparable, V any](fn func(k KF) KT, m map[KF]V) map[KT]V

func MapValues

func MapValues[K comparable, VF, VT any](fn func(v VF) VT, m map[K]VF) map[K]VT

func Put

func Put[K comparable, V any](m map[K]V, k K, v V)

func SetDefault

func SetDefault[K comparable, V any](m map[K]V, k K, d V) V

func TryGet

func TryGet[K comparable, V any](m map[K]V, k K) (V, bool)

func Update

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

func Values

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

Types

type Builder

type Builder[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func NewBuilder

func NewBuilder[K comparable, V any](m map[K]V) *Builder[K, V]

func (*Builder[K, V]) Build

func (b *Builder[K, V]) Build() map[K]V

func (*Builder[K, V]) Default

func (b *Builder[K, V]) Default(k K, v V) *Builder[K, V]

func (*Builder[K, V]) Delete

func (b *Builder[K, V]) Delete(k K) *Builder[K, V]

func (*Builder[K, V]) Filter

func (b *Builder[K, V]) Filter(fn func(k K, v V) bool) *Builder[K, V]

func (*Builder[K, V]) FilterKeys

func (b *Builder[K, V]) FilterKeys(fn func(k K) bool) *Builder[K, V]

func (*Builder[K, V]) FilterKv

func (b *Builder[K, V]) FilterKv(fn func(kv bt.Kv[K, V]) bool) *Builder[K, V]

func (*Builder[K, V]) FilterValues

func (b *Builder[K, V]) FilterValues(fn func(v V) bool) *Builder[K, V]

func (*Builder[K, V]) Put

func (b *Builder[K, V]) Put(k K, v V) *Builder[K, V]

func (*Builder[K, V]) Update

func (b *Builder[K, V]) Update(m map[K]V) *Builder[K, V]

func (*Builder[K, V]) UpdateKv

func (b *Builder[K, V]) UpdateKv(it bt.Iterable[bt.Kv[K, V]]) *Builder[K, V]

type Set

type Set[T comparable] map[T]struct{}

func MakeSet

func MakeSet[T comparable]() Set[T]

func MakeSetOf

func MakeSetOf[T comparable](vs []T) Set[T]

func (Set[T]) Add

func (s Set[T]) Add(v T)

func (Set[T]) AddAll

func (s Set[T]) AddAll(vs []T)

func (Set[T]) Contains

func (s Set[T]) Contains(v T) bool

func (Set[T]) Equals

func (s Set[T]) Equals(o Set[T]) bool

func (Set[T]) Remove

func (s Set[T]) Remove(v T)

func (Set[T]) RemoveAll

func (s Set[T]) RemoveAll(vs []T)

func (Set[T]) Slice

func (s Set[T]) Slice() []T

func (Set[T]) Update

func (s Set[T]) Update(o Set[T])

type TypeSet

type TypeSet map[reflect.Type]struct{}

func NewTypeSet

func NewTypeSet(s []reflect.Type) TypeSet

Jump to

Keyboard shortcuts

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