mapp

package
v0.0.0-...-e8daaa7 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 4 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clone

func Clone(m map[string]string) map[string]string

Clone clones a map[string]string.

func GetOr

func GetOr(m, k, defaultValue interface{}) interface{}

GetOr get value from m by key or returns the defaultValue

func GetStringOr

func GetStringOr(m map[string]string, key, defValue string) string

GetStringOr returns the value associated to the key, or return defValue when value does not exit, or it is empty.

func Keys

func Keys(m interface{}) []string

Keys 返回Map的key切片

func KeysSorted

func KeysSorted(m interface{}) []string

KeysSorted 返回Map排序后的key切片

func KeysSortedX

func KeysSortedX(m interface{}) interface{}

KeysSortedX 返回Map排序后的key切片

func KeysX

func KeysX(m interface{}) interface{}

KeysX 返回Map的key切片

func MapValuesX

func MapValuesX(m interface{}) interface{}

MapValuesX 返回Map的value切片

func Values

func Values(m interface{}) []string

Values 返回Map的value切片

func WalkMap

func WalkMap(m interface{}, iterFunc interface{})

WalkMap iterates the map by iterFunc.

Types

type SafeMap

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

SafeMap provides a map alternative to avoid memory leak. This implementation is not needed until issue below fixed. https://github.com/golang/go/issues/20135

func NewSafeMap

func NewSafeMap() *SafeMap

NewSafeMap returns a SafeMap.

func (*SafeMap) Del

func (m *SafeMap) Del(key interface{})

Del deletes the value with the given key from m.

func (*SafeMap) Get

func (m *SafeMap) Get(key interface{}) (interface{}, bool)

Get gets the value with the given key from m.

func (*SafeMap) Range

func (m *SafeMap) Range(f func(key, val interface{}) bool)

Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration.

func (*SafeMap) Set

func (m *SafeMap) Set(key, value interface{})

Set sets the value into m with the given key.

func (*SafeMap) Size

func (m *SafeMap) Size() int

Size returns the size of m.

Jump to

Keyboard shortcuts

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