orderedmap

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2023 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package orderedmap provides a map that remembers the order keys were inserted.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OrderedMap

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

OrderedMap is a map that remembers the order that keys were assorted. To iterate in order, iterate over the keys and call Get on valueMap

func NewOrderedMap

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

NewOrderedMap returns a new empty OrderedMap.

func (*OrderedMap[K, V]) Delete

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

Delete removes the key and value from OrderedMap. Delete is O(n).

func (*OrderedMap[K, V]) Get

func (o *OrderedMap[K, V]) Get(key K) (value V, found bool)

Get returns a value corresponding the key. If the key is not found, the zero value of K is returned with found being false. Get is O(1).

func (*OrderedMap[K, V]) Keys

func (o *OrderedMap[K, V]) Keys() []K

Keys returns the list of Keys to iterate over.

func (*OrderedMap[K, V]) Len

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

Len returns a size of OrderedMap.

func (*OrderedMap[K, V]) Set

func (o *OrderedMap[K, V]) Set(key K, value V)

Set stores the value and stores the order in which it was set. If this overrides a value, also update the order the keys were set. Set is O(n).

Jump to

Keyboard shortcuts

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