partmap

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: MIT Imports: 3 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 is a concurrent map with string keys and generic values, partitioned for better concurrency.

func NewMap

func NewMap[V any](partitions int) *Map[V]

NewMap creates a new Map with the specified number of partitions.

func (*Map[V]) Count

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

Count returns the number of key-value pairs in the map.

func (*Map[V]) Delete

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

Delete removes the value for a given key.

func (*Map[V]) Each

func (m *Map[V]) Each(fn func(key string, value V) error) error

Each applies a function to each key-value pair in the map.

func (*Map[V]) Get

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

Get retrieves the value for a given key.

func (*Map[V]) GetOrCreate

func (m *Map[V]) GetOrCreate(key string, fn func() (V, error)) (V, error)

GetOrCreate retrieves the value for a given key or creates it using the provided function.

func (*Map[V]) Mutate added in v0.2.0

func (m *Map[V]) Mutate(key string, fn func(value V) (V, error)) error

Mutate applies a function to the value for a given key and sets the returned value atomically.

func (*Map[V]) Set

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

Set sets the value for a given key.

Jump to

Keyboard shortcuts

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