mapx

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2025 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

type Map[V any] struct {
	// contains filtered or unexported fields
}

Map a wrapper for sync.Map to support generic

func (*Map[V]) Delete

func (m *Map[V]) Delete(key string) bool

func (*Map[V]) Len

func (m *Map[V]) Len() int

func (*Map[V]) Load

func (m *Map[V]) Load(key string) (value V, ok bool)

func (*Map[V]) LoadAndDelete

func (m *Map[V]) LoadAndDelete(key string) (value V, loaded bool)

func (*Map[V]) LoadOrStore

func (m *Map[V]) LoadOrStore(key string, value V) (actual V, loaded bool)

func (*Map[V]) LoadOrStoreLazy

func (m *Map[V]) LoadOrStoreLazy(key string, lazy func() V) (actual V, loaded bool)

func (*Map[V]) Range

func (m *Map[V]) Range(f func(key string, value V) bool)

func (*Map[V]) Store

func (m *Map[V]) Store(key string, value V)

type SyncStringMap

type SyncStringMap[V any] interface {
	Delete(key string) bool
	Load(key string) (value V, ok bool)
	LoadAndDelete(key string) (value V, loaded bool)
	LoadOrStore(key string, value V) (actual V, loaded bool)
	LoadOrStoreLazy(key string, lazy func() V) (actual V, loaded bool)
	Range(f func(key string, value V) bool)
	Store(key string, value V)
	Len() int
}

func New

func New[V any]() SyncStringMap[V]

Jump to

Keyboard shortcuts

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