ordermap

package
v0.0.0-...-d5b31fc Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2020 License: MIT Imports: 2 Imported by: 0

README

OrderMap

map with ordered keys (string key only)

Usage

    m := ordermap.New()
    m.Set("n", 100)
    m.Set("f", 99.99)
    m.Set("d", "barfoo")
    m.Set("c", "foobar")
    m.Set("b", "bar")
    m.Set("a", "foo")

	// use Keys() to iterate all ordered keys
    for _, key := range m.Keys() {
        fmt.Println(key, m.Get(key))
    }
    json.NewEncoder(os.Stdout).Encode(m)

    m.Del("c")
    for _, key := range m.Keys() {
        fmt.Println(key, m.Get(key))
    }
    json.NewEncoder(os.Stdout).Encode(m)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OrderMap

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

func New

func New() *OrderMap

func (*OrderMap) Del

func (o *OrderMap) Del(key string)

func (*OrderMap) Get

func (o *OrderMap) Get(key string) interface{}

func (*OrderMap) Keys

func (o *OrderMap) Keys() []string

Keys return the ordered keys of params map

func (*OrderMap) Len

func (o *OrderMap) Len() int

implement sort.Interface

func (*OrderMap) Less

func (o *OrderMap) Less(i int, j int) bool

func (*OrderMap) MarshalJSON

func (o *OrderMap) MarshalJSON() ([]byte, error)

MarshalJSON implement json.Marshaler

func (*OrderMap) Set

func (o *OrderMap) Set(key string, value interface{})

func (*OrderMap) Swap

func (o *OrderMap) Swap(i int, j int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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