maputil

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AreEqual

func AreEqual[K comparable](map1, map2 map[K]string) bool

AreEqual checks if two maps are equal.

func Merge

func Merge[K comparable, V any](ms ...map[K]V) map[K]V

Merge merges all maps to a new one.

func MergeTo

func MergeTo[K comparable, V any](original map[K]V, ms ...map[K]V) map[K]V

MergeTo merges all maps to the original one.

func Select

func Select[K comparable, V any](originalMap map[K]V, keys ...K) map[K]V

Select returns a new map with selected keys and values of the originalMap

Types

type Map

type Map[K comparable, V any] struct {
	sync.Map
}

Map is a wrapper of sync.Map to avoid type assertion in the outer function

func (*Map[K, V]) Delete

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

func (*Map[K, V]) Load

func (m *Map[K, V]) Load(k K) (_ V, _ bool)

func (*Map[K, V]) LoadAndDelete

func (m *Map[K, V]) LoadAndDelete(k K) (_ V, _ bool)

func (*Map[K, V]) LoadOrStore

func (m *Map[K, V]) LoadOrStore(k K, v V) (_ V, _ bool)

func (*Map[K, V]) Range

func (m *Map[K, V]) Range(f func(K, V) bool)

func (*Map[K, V]) Store

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

func (*Map[K, V]) Swap

func (m *Map[K, V]) Swap(k K, v V) (_ V, _ bool)

Jump to

Keyboard shortcuts

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