orderedmap

package
v1.0.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: Apache-2.0, BSD-2-Clause Imports: 5 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Element

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

Element defines the model of each element of the orderedMap.

type OrderedMap

type OrderedMap[K comparable, V any] struct {
	*orderedmap.OrderedMap
}

OrderedMap provides a concurrent-safe ordered map.

func New

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

New returns a new *OrderedMap.

func (*OrderedMap[K, V]) Clone

func (orderedMap *OrderedMap[K, V]) Clone() (cloned *OrderedMap[K, V])

Clone returns a copy of the orderedMap.

func (*OrderedMap[K, V]) Decode

func (orderedMap *OrderedMap[K, V]) Decode(b []byte) (bytesRead int, err error)

Decode deserializes bytes into a valid object.

func (*OrderedMap[K, V]) Delete

func (orderedMap *OrderedMap[K, V]) Delete(key K) bool

Delete deletes the given key (and related value) from the orderedMap. It returns false if the key is not found.

func (*OrderedMap[K, V]) Encode

func (orderedMap *OrderedMap[K, V]) Encode() ([]byte, error)

Encode returns a serialized byte slice of the object.

func (*OrderedMap[K, V]) ForEach

func (orderedMap *OrderedMap[K, V]) ForEach(consumer func(key K, value V) bool) bool

ForEach iterates through the orderedMap and calls the consumer function for every element. The iteration can be aborted by returning false in the consumer.

func (*OrderedMap[K, V]) ForEachReverse

func (orderedMap *OrderedMap[K, V]) ForEachReverse(consumer func(key K, value V) bool) bool

ForEachReverse iterates through the orderedMap in reverse order and calls the consumer function for every element. The iteration can be aborted by returning false in the consumer.

func (*OrderedMap[K, V]) Get

func (orderedMap *OrderedMap[K, V]) Get(key K) (value V, exists bool)

Get returns the value mapped to the given key if exists.

func (*OrderedMap[K, V]) Has

func (orderedMap *OrderedMap[K, V]) Has(key K) (has bool)

Has returns if an entry with the given key exists.

func (*OrderedMap[K, V]) Head

func (orderedMap *OrderedMap[K, V]) Head() (key K, value V, exists bool)

Head returns the first map entry.

func (*OrderedMap[K, V]) Set

func (orderedMap *OrderedMap[K, V]) Set(key K, newValue V) bool

Set adds a key-value pair to the orderedMap. It returns false if the same pair already exists.

func (*OrderedMap[K, V]) Tail

func (orderedMap *OrderedMap[K, V]) Tail() (key K, value V, exists bool)

Tail returns the last map entry.

Jump to

Keyboard shortcuts

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