immutable

package
v0.10.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

The immutable package defines immutable wrappers around common data structures. These are used for additional type safety inside gopls.

See the "persistent" package for copy-on-write data structures.

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 an immutable wrapper around an ordinary Go map.

func MapOf

func MapOf[K comparable, V any](m map[K]V) Map[K, V]

MapOf wraps the given Go map.

The caller must not subsequently mutate the map.

func (Map[K, V]) Len

func (m Map[K, V]) Len() int

Len returns the number of entries in the Map.

func (Map[K, V]) Range

func (m Map[K, V]) Range(f func(k K, v V))

Range calls f for each mapped (key, value) pair. There is no way to break out of the loop. TODO: generalize when Go iterators (#61405) land.

func (Map[K, V]) Value

func (m Map[K, V]) Value(k K) (V, bool)

Value returns the mapped value for k. It is equivalent to the commaok form of an ordinary go map, and returns (zero, false) if the key is not present.

Jump to

Keyboard shortcuts

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