nummap

package module
v0.0.0-...-d5f33ea Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package nummap provides maps of arbitrary keys to numeric values that can be accessed concurrently and read-edit-written atomically.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NumMap

type NumMap[K comparable, V oil.Number] struct {
	// contains filtered or unexported fields
}

NumMap maps any type of key to any type of number and allows to manipulate those numbers in a concurrency safe fashion.

func NewNumMap

func NewNumMap[K comparable, V oil.Number]() *NumMap[K, V]

NewNumMap creates a NumMap.

func (*NumMap[K, V]) Add

func (cm *NumMap[K, V]) Add(key K, value V) V

Add adds a value to an entry of the map and returns the result.

func (*NumMap[K, V]) Apply

func (cm *NumMap[K, V]) Apply(key K, f func(v V) V) (before, after V)

Apply applies an arbitrary function to an entry of the map and returns the result and the initial value.

func (*NumMap[K, V]) Delete

func (cm *NumMap[K, V]) Delete(key K)

Delete deletes an entry from the NumMap.

func (*NumMap[K, V]) Get

func (cm *NumMap[K, V]) Get(k K) V

Get reads an entry of the map.

func (*NumMap[K, V]) Len

func (cm *NumMap[K, V]) Len() int

Len returns the NumMap len.

func (*NumMap[K, V]) Set

func (cm *NumMap[K, V]) Set(k K, v V)

Set sets an entry of the map to a value.

func (*NumMap[K, V]) Snapshot

func (cm *NumMap[K, V]) Snapshot() map[K]V

Snapshot returns a snapshot copy of the map.

func (*NumMap[K, V]) Sub

func (cm *NumMap[K, V]) Sub(key K, value V) V

Sub subtracts a value from an entry of the map and returns the result.

Jump to

Keyboard shortcuts

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