maps

package
v0.0.0-...-8e7861b Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: Apache-2.0 Imports: 6 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ComplexKeyMap

type ComplexKeyMap[K comparable, V any] map[K]V

A map whose keys are complex enough that the map is represented in JSON as a list of key-value pairs.

func NewComplexKeyMap

func NewComplexKeyMap[K comparable, V any]() ComplexKeyMap[K, V]

func (ComplexKeyMap[K, V]) Add

func (m ComplexKeyMap[K, V]) Add(other ComplexKeyMap[K, V], onConflict func(v, newV V) V)

func (ComplexKeyMap[K, V]) ContainsKey

func (m ComplexKeyMap[K, V]) ContainsKey(k K) bool

func (ComplexKeyMap[K, V]) Delete

func (m ComplexKeyMap[K, V]) Delete(k K)

func (ComplexKeyMap[K, V]) Get

func (m ComplexKeyMap[K, V]) Get(k K) optionals.Optional[V]

func (ComplexKeyMap[K, V]) GetOrCompute

func (m ComplexKeyMap[K, V]) GetOrCompute(k K, computeValue func() (V, error)) (V, error)

Returns the value associated with the given key k. If the key does not already exist in the map, the supplied function is called, and the resulting value is entered into the map and returned.

func (ComplexKeyMap[K, V]) GetOrComputeNoError

func (m ComplexKeyMap[K, V]) GetOrComputeNoError(k K, computeValue func() V) V

A version of GetOrCompute that is guaranteed to not error.

func (ComplexKeyMap[K, V]) GetOrDefault

func (m ComplexKeyMap[K, V]) GetOrDefault(k K) V

Returns the value associated with the given key k. If the key does not already exist in the map, the default Go value is returned.

func (ComplexKeyMap[K, V]) GetOrValue

func (m ComplexKeyMap[K, V]) GetOrValue(k K, value V) V

Returns the value associated with the given key k. If the key does not already exist in the map, the supplied value is entered into the map and returned.

func (ComplexKeyMap[K, V]) IsEmpty

func (m ComplexKeyMap[K, V]) IsEmpty() bool

func (ComplexKeyMap[K, V]) MarshalJSON

func (m ComplexKeyMap[K, V]) MarshalJSON() ([]byte, error)

func (ComplexKeyMap[K, V]) Put

func (m ComplexKeyMap[K, V]) Put(k K, v V)

func (ComplexKeyMap[K, V]) Size

func (m ComplexKeyMap[K, V]) Size() int

func (*ComplexKeyMap[K, V]) UnmarshalJSON

func (m *ComplexKeyMap[K, V]) UnmarshalJSON(text []byte) error

func (ComplexKeyMap[K, V]) Upsert

func (m ComplexKeyMap[K, V]) Upsert(k K, v V, onConflict func(v, newV V) V)

type Map

type Map[K comparable, V any] map[K]V

func NewMap

func NewMap[K comparable, V any]() Map[K, V]

func (Map[K, V]) Add

func (m Map[K, V]) Add(other Map[K, V], onConflict func(v, newV V) V)

func (Map[K, V]) ComputeIfAbsent

func (m Map[K, V]) ComputeIfAbsent(k K, computeValue func() (V, error)) error

If the key k is not already in the map, then it is entered into the map with the result of calling the supplied function. If the function returns an error, then the map is not modified, and the error is returned.

func (Map[K, V]) ComputeIfAbsentNoError

func (m Map[K, V]) ComputeIfAbsentNoError(k K, computeValue func() V)

If the key k is not already in the map, then it is entered into the map with the result of calling the supplied function.

func (Map[K, V]) ContainsKey

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

func (Map[K, V]) Delete

func (m Map[K, V]) Delete(k K)

func (Map[K, V]) Get

func (m Map[K, V]) Get(k K) optionals.Optional[V]

func (Map[K, V]) GetOrCompute

func (m Map[K, V]) GetOrCompute(k K, computeValue func() (V, error)) (V, error)

Returns the value associated with the given key k. If the key does not already exist in the map, the supplied function is called, and the resulting value is entered into the map and returned.

func (Map[K, V]) GetOrComputeNoError

func (m Map[K, V]) GetOrComputeNoError(k K, computeValue func() V) V

Returns the value associated with the given key k. If the key does not already exist in the map, the supplied function is called, and the resulting value is entered into the map and returned.

func (Map[K, V]) GetOrDefault

func (m Map[K, V]) GetOrDefault(k K) V

Returns the value associated with the given key k. If the key does not already exist in the map, the default Go value is returned.

func (Map[K, V]) GetOrValue

func (m Map[K, V]) GetOrValue(k K, value V) V

Returns the value associated with the given key k. If the key does not already exist in the map, the supplied value is entered into the map and returned.

func (Map[K, V]) IsEmpty

func (m Map[K, V]) IsEmpty() bool

func (Map[K, V]) KeySet

func (m Map[K, V]) KeySet() sets.Set[K]

func (Map[K, V]) Keys

func (m Map[K, V]) Keys() []K

func (Map[K, V]) Put

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

func (Map[K, V]) PutIfAbsent

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

If the key k is not already in the map, then it is entered into the map with the value v.

func (Map[K, V]) Size

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

func (Map[K, V]) Upsert

func (m Map[K, V]) Upsert(k K, v V, onConflict func(v, newV V) V)

func (Map[K, V]) Values

func (m Map[K, V]) Values() []V

type SliceElt

type SliceElt[K comparable, V any] struct {
	Key   K `json:"key"`
	Value V `json:"value"`
}

type TimeMap

type TimeMap[V any] struct {
	// contains filtered or unexported fields
}

func NewTimeMap

func NewTimeMap[V any]() TimeMap[V]

func (TimeMap[V]) Add

func (m TimeMap[V]) Add(other TimeMap[V], onConflict func(v, newV V) V)

func (TimeMap[V]) ComputeIfAbsent

func (m TimeMap[V]) ComputeIfAbsent(k time.Time, computeValue func() (V, error)) error

If the key k is not already in the map, then it is entered into the map with the result of calling the supplied function. If the function returns an error, then the map is not modified, and the error is returned.

func (TimeMap[V]) ComputeIfAbsentNoError

func (m TimeMap[V]) ComputeIfAbsentNoError(k time.Time, computeValue func() V)

If the key k is not already in the map, then it is entered into the map with the result of calling the supplied function.

func (TimeMap[V]) ContainsKey

func (m TimeMap[V]) ContainsKey(k time.Time) bool

func (TimeMap[V]) Delete

func (m TimeMap[V]) Delete(k time.Time)

func (TimeMap[V]) Get

func (m TimeMap[V]) Get(k time.Time) optionals.Optional[V]

func (TimeMap[V]) GetOrCompute

func (m TimeMap[V]) GetOrCompute(k time.Time, computeValue func() (V, error)) (V, error)

Returns the value associated with the given key k. If the key does not already exist in the map, the supplied function is called, and the resulting value is entered into the map and returned.

func (TimeMap[V]) GetOrComputeNoError

func (m TimeMap[V]) GetOrComputeNoError(k time.Time, computeValue func() V) V

Returns the value associated with the given key k. If the key does not already exist in the map, the supplied function is called, and the resulting value is entered into the map and returned.

func (TimeMap[V]) GetOrDefault

func (m TimeMap[V]) GetOrDefault(k time.Time) V

Returns the value associated with the given key k. If the key does not already exist in the map, the default Go value is returned.

func (TimeMap[V]) GetOrValue

func (m TimeMap[V]) GetOrValue(k time.Time, value V) V

Returns the value associated with the given key k. If the key does not already exist in the map, the supplied value is entered into the map and returned.

func (TimeMap[V]) IsEmpty

func (m TimeMap[V]) IsEmpty() bool

func (TimeMap[V]) KeySet

func (m TimeMap[V]) KeySet() sets.Set[time.Time]

func (TimeMap[V]) Keys

func (m TimeMap[V]) Keys() []time.Time

func (TimeMap[V]) Put

func (m TimeMap[V]) Put(k time.Time, v V)

func (TimeMap[V]) PutIfAbsent

func (m TimeMap[V]) PutIfAbsent(k time.Time, v V)

If the key k is not already in the map, then it is entered into the map with the value v.

func (TimeMap[V]) Size

func (m TimeMap[V]) Size() int

func (TimeMap[V]) Upsert

func (m TimeMap[V]) Upsert(k time.Time, v V, onConflict func(v, newV V) V)

func (TimeMap[V]) Values

func (m TimeMap[V]) Values() []V

Jump to

Keyboard shortcuts

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