orderedmap

package
v0.42.11 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: Apache-2.0 Imports: 1 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New added in v0.26.0

func New[T OrderedMap[K, V], K comparable, V any](size int) *T

New returns a new OrderedMap of the given size

Types

type OrderedMap added in v0.25.0

type OrderedMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

OrderedMap

func (*OrderedMap[K, V]) Clear added in v0.25.0

func (om *OrderedMap[K, V]) Clear()

Clear removes all entries from this ordered map.

func (*OrderedMap[K, V]) Contains added in v0.28.0

func (om *OrderedMap[K, V]) Contains(key K) (present bool)

Contains returns true if the key is present in the map and false otherwise.

func (*OrderedMap[K, V]) Delete added in v0.25.0

func (om *OrderedMap[K, V]) Delete(key K) (oldValue V, present bool)

Delete removes the key-value pair, and returns what `Get` would have returned on that key prior to the call to `Delete`.

func (*OrderedMap[K, V]) Foreach added in v0.25.0

func (om *OrderedMap[K, V]) Foreach(f func(key K, value V))

Foreach iterates over the entries of the map in the insertion order, and invokes the provided function for each key-value pair.

func (*OrderedMap[K, V]) ForeachWithError added in v0.25.0

func (om *OrderedMap[K, V]) ForeachWithError(f func(key K, value V) error) error

ForeachWithError iterates over the entries of the map in the insertion order, and invokes the provided function for each key-value pair. If the passed function returns an error, iteration breaks and the error is returned.

func (*OrderedMap[K, V]) Get added in v0.25.0

func (om *OrderedMap[K, V]) Get(key K) (result V, present bool)

Get returns the value associated with the given key. Returns nil if not found. The second return value indicates if the key is present in the map.

func (*OrderedMap[K, V]) GetPair added in v0.25.0

func (om *OrderedMap[K, V]) GetPair(key K) *Pair[K, V]

GetPair returns the key-value pair associated with the given key. Returns nil if not found.

func (*OrderedMap[K, V]) Len added in v0.25.0

func (om *OrderedMap[K, V]) Len() int

Len returns the length of the ordered map.

func (*OrderedMap[K, V]) Newest added in v0.25.0

func (om *OrderedMap[K, V]) Newest() *Pair[K, V]

Newest returns a pointer to the newest pair.

func (*OrderedMap[K, V]) Oldest added in v0.25.0

func (om *OrderedMap[K, V]) Oldest() *Pair[K, V]

Oldest returns a pointer to the oldest pair.

func (*OrderedMap[K, V]) Set added in v0.25.0

func (om *OrderedMap[K, V]) Set(key K, value V) (oldValue V, present bool)

Set sets the key-value pair, and returns what `Get` would have returned on that key prior to the call to `Set`.

type Pair added in v0.25.0

type Pair[K any, V any] struct {
	Key   K
	Value V
	// contains filtered or unexported fields
}

Pair is an entry in an OrderedMap

func (Pair[K, V]) Next added in v0.25.0

func (p Pair[K, V]) Next() *Pair[K, V]

Next returns a pointer to the next pair.

func (Pair[K, V]) Prev added in v0.25.0

func (p Pair[K, V]) Prev() *Pair[K, V]

Prev returns a pointer to the previous pair.

Jump to

Keyboard shortcuts

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