ordered

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package ordered implements a simple ordered map to ensure that the insertion order in the elements of a map is maintained.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

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

Map represents an ordered map.

func NewMap

func NewMap() *Map

NewMap creates a new ordered map object.

func (*Map) Append

func (m *Map) Append(key string, value interface{})

Append appends a new key-value pair to the map. If the key already exists the value will be overwritten.

func (*Map) Has

func (m *Map) Has(key string) bool

Has checks if map contains given key.

func (*Map) Iterate

func (m *Map) Iterate(iterator mapIterator)

Iterate iterates through the map key-value pairs. If the passed function returns false the iteration will stop and Iterate returns immediately.

func (*Map) Len

func (m *Map) Len() int

Len returns the number of kay-value pairs in the map.

func (*Map) String

func (m *Map) String() string

String implements the stringer interface.

func (*Map) Value

func (m *Map) Value(key string) interface{}

Value returns the value for given key, nil if key don't exist.

Jump to

Keyboard shortcuts

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