Documentation
¶
Overview ¶
Package ordered contains of ordered map structure and methods
Index ¶
Examples ¶
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 stores data in ordered way, where key is equal to value
func NewMap ¶
func NewMap() *Map
NewMap creates new instance of Map
Example ¶
m := NewMap() fmt.Println(reflect.TypeOf(m), m.Len())
Output: *ordered.Map 0
func (*Map) Add ¶
func (om *Map) Add(key interface{}) interface{}
Add pushes new element to a map. If element has already exists it will return ald value
Example ¶
m := NewMap()
fmt.Println(m.Add("abc"), m.Add("bcd"), m.Add("abc"))
Output: abc bcd abc
func (*Map) Delete ¶
Delete will remove a key from the map. It will return true if the key was removed (the key did exist).
Example ¶
m := NewMap()
m.Add("abc")
fmt.Println(m.Delete("abc"), m.Delete("abc"))
Output: true false
func (*Map) Get ¶
func (m *Map) Get(key interface{}) interface{}
Get returns the value for a key.
Example ¶
m := NewMap()
m.Add("abc")
fmt.Println(m.Get("abc"), m.Get("bcd"))
Output: abc <nil>
Click to show internal directories.
Click to hide internal directories.