pmap

package
v0.43.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 0 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package pmap provides an immutable persistent AVL map keyed by strings.

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 an immutable persistent AVL map from string keys to values of type V.

Its zero value is an empty map. Updates return a new map and never modify the receiver or any node reachable from it, so existing roots remain usable. A Map should be treated as immutable; its roots can safely be shared between goroutines provided values stored in it are themselves used safely.

func New

func New[V any]() *Map[V]

New returns an empty map.

func (*Map[V]) Get

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

Get returns the value associated with key and whether key is present. It is safe to call Get on a nil *Map.

func (*Map[V]) Len

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

Len returns the number of keys in the map. It is safe to call Len on a nil *Map.

func (*Map[V]) Range

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

Range calls yield for each key/value pair in ascending key order. If yield returns false, Range stops immediately. A nil callback is treated as an immediate stop. It is safe to call Range on a nil *Map.

func (*Map[V]) Set

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

Set returns a new map containing key mapped to value. The receiver and all previously returned maps are left unchanged. If key already exists, its value is replaced without changing the map's length. Set is also safe on a nil *Map; in that case it behaves like an update to an empty map.

Jump to

Keyboard shortcuts

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