memory

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2025 License: MIT 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[K comparable, V any] struct {
	// contains filtered or unexported fields
}

Map is a thread-safe map using sync.Map with generics

func New

func New[K comparable, V any]() *Map[K, V]

New creates a new Map

func (*Map[K, V]) AsMap

func (g *Map[K, V]) AsMap() map[K]V

AsMap returns a regular map containing all key-value pairs

func (*Map[K, V]) Clear

func (g *Map[K, V]) Clear()

Clear removes all key-value pairs from the map

func (*Map[K, V]) Clone

func (g *Map[K, V]) Clone() storage.IMap[K, V]

Clone creates a shallow copy of the map

func (*Map[K, V]) Del

func (g *Map[K, V]) Del(key K)

Del removes a key-value pair from the map

func (*Map[K, V]) ForEach

func (g *Map[K, V]) ForEach(fn func(K, V) bool)

ForEach iterates over the map

func (*Map[K, V]) Get

func (g *Map[K, V]) Get(key K) (V, bool)

Get retrieves the value for a given key

func (*Map[K, V]) Keys

func (g *Map[K, V]) Keys() []K

Keys returns a slice of all keys in the map

func (*Map[K, V]) Set

func (g *Map[K, V]) Set(key K, value V)

Set adds a key-value pair to the map

func (*Map[K, V]) Size

func (g *Map[K, V]) Size() int

Size returns the number of key-value pairs in the map

func (*Map[K, V]) Values

func (g *Map[K, V]) Values() []V

Values returns a slice of all values in the map

Jump to

Keyboard shortcuts

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