xorderedmap

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2021 License: MIT Imports: 7 Imported by: 0

README

xorderedmap

Dependencies

  • xreflect
  • xtesting*

Documents

Types
  • type OrderedMap struct
Variables
  • None
Constants
  • None
Functions
  • func New() *OrderedMap
  • func FromInterface(object interface{}) *OrderedMap
Methods
  • func (l *OrderedMap) Keys() []string
  • func (l *OrderedMap) Values() []interface{}
  • func (l *OrderedMap) Len() int
  • func (l *OrderedMap) Set(key string, value interface{})
  • func (l *OrderedMap) Has(key string) bool
  • func (l *OrderedMap) Get(key string) (interface{}, bool)
  • func (l *OrderedMap) GetOr(key string, defaultValue interface{}) interface{}
  • func (l *OrderedMap) MustGet(key string) interface{}
  • func (l *OrderedMap) Remove(key string) (interface{}, bool)
  • func (l *OrderedMap) Clear()
  • func (l *OrderedMap) MarshalJSON() ([]byte, error)
  • func (l *OrderedMap) MarshalYAML() (interface{}, error)
  • func (l *OrderedMap) String() string

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OrderedMap

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

OrderedMap represents a map which is in ordered. This type is concurrent safe.

func FromInterface

func FromInterface(object interface{}) *OrderedMap

FromInterface creates an OrderedMap from a struct (with json tag), panics if using nil or non-struct object.

func New

func New() *OrderedMap

New creates an empty OrderedMap.

func (*OrderedMap) Clear

func (l *OrderedMap) Clear()

Clear clears the OrderedMap.

func (*OrderedMap) Get

func (l *OrderedMap) Get(key string) (interface{}, bool)

Get returns the value by key, returns false if the key not found.

func (*OrderedMap) GetOr

func (l *OrderedMap) GetOr(key string, defaultValue interface{}) interface{}

GetOr returns the value by key, returns defaultValue if the key not found.

func (*OrderedMap) Has

func (l *OrderedMap) Has(key string) bool

Has returns true if key exists.

func (*OrderedMap) Keys

func (l *OrderedMap) Keys() []string

Keys returns the keys in ordered.

func (*OrderedMap) Len

func (l *OrderedMap) Len() int

Len returns the length of OrderedMap.

func (*OrderedMap) MarshalJSON

func (l *OrderedMap) MarshalJSON() ([]byte, error)

MarshalJSON marshals OrderedMap to json bytes.

func (*OrderedMap) MarshalYAML

func (l *OrderedMap) MarshalYAML() (interface{}, error)

MarshalYAML marshals OrderedMap to yaml supported object (in no ordered). Details see https://blog.labix.org/2014/09/22/announcing-yaml-v2-for-go and https://github.com/go-yaml/yaml/issues/30#issuecomment-56246239.

func (*OrderedMap) MustGet

func (l *OrderedMap) MustGet(key string) interface{}

MustGet returns the value by key, panics if the key not found.

func (*OrderedMap) Remove

func (l *OrderedMap) Remove(key string) (interface{}, bool)

Remove removes the key-value pair by key, returns false if the key not found.

func (*OrderedMap) Set

func (l *OrderedMap) Set(key string, value interface{})

Set sets a key-value pair, note that it does not change the order for the existed key.

func (*OrderedMap) String

func (l *OrderedMap) String() string

String returns the string in json format.

func (*OrderedMap) Values

func (l *OrderedMap) Values() []interface{}

Values returns the values in ordered.

Jump to

Keyboard shortcuts

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