orderedmap

package module
v0.0.0-...-b4c53eb Latest Latest
Warning

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

Go to latest
Published: May 21, 2018 License: MIT Imports: 0 Imported by: 0

README

orderedmap

Go ordered map. Documentation: godoc

Can be used with go code generator to generate a type safe ordered map, such as:

ccg -f github.com/millerlogic/orderedmap -t KeyType=int,ValueType=string -r OrderedMap=IntStringOrderedMap,NewOrderedMap=NewIntStringOrderedMap,link=intstringlink -o intstringorderedmap.go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyType

type KeyType interface{}

KeyType is the map key type, can be generically overridden.

type OrderedMap

type OrderedMap struct {
	// contains filtered or unexported fields
}

OrderedMap is an ordered map collection. Not thread safe, but exposes the same interface as sync.Map

func NewOrderedMap

func NewOrderedMap() *OrderedMap

NewOrderedMap makes a new OrderedMap

func (*OrderedMap) Clear

func (m *OrderedMap) Clear()

Clear clears the map back to an empty state of no keys.

func (*OrderedMap) Delete

func (m *OrderedMap) Delete(key KeyType)

Delete deletes this key from the map

func (*OrderedMap) Len

func (m *OrderedMap) Len() int

Len returns the number of items in the map.

func (*OrderedMap) Load

func (m *OrderedMap) Load(key KeyType) (value ValueType, ok bool)

Load loads this key from the map

func (*OrderedMap) LoadOrStore

func (m *OrderedMap) LoadOrStore(key KeyType, value ValueType) (actual ValueType, loaded bool)

LoadOrStore loads or stores

func (*OrderedMap) Range

func (m *OrderedMap) Range(f func(key KeyType, value ValueType) bool)

Range iterates over the key/value pairs in order

func (*OrderedMap) Store

func (m *OrderedMap) Store(key KeyType, value ValueType)

Store stores this key/value pair in the map

type ValueType

type ValueType interface{}

ValueType is the map value type, can be generically overridden.

Jump to

Keyboard shortcuts

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