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 (*Map[V]) Get ¶
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 ¶
Len returns the number of keys in the map. It is safe to call Len on a nil *Map.
func (*Map[V]) Range ¶
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 ¶
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.