ordereddict

package
v0.0.0-...-b3a60a0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: Apache-2.0, Apache-2.0 Imports: 3 Imported by: 0

README

# Ordered Dict implementation for go.

There are a number of OrderedDict implementations out there and this
is one is less capable than a more generic implementation:

- We do not support key deletion
- Replacing a key is O(n) with the number of keys

Therefore this implementation is only suitable for dicts with few keys
that are not generally replaced or deleted.

The main benefit of this implementation is that it maintains key order
when serializing/unserializing from JSON and it is very memory
efficient.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAny

func GetAny(event_map *Dict, members string) (interface{}, bool)

func GetInt

func GetInt(event_map *Dict, members string) (int, bool)

func GetString

func GetString(event_map *Dict, members string) (string, bool)

Types

type Dict

type Dict struct {
	sync.Mutex
	// contains filtered or unexported fields
}

A concrete implementation of a row - similar to Python's OrderedDict. Main difference is that delete is not implemented - we just preserve the order of insertions.

func GetMap

func GetMap(event_map *Dict, members string) (*Dict, bool)

func NewDict

func NewDict() *Dict

func (*Dict) Delete

func (self *Dict) Delete(key string)

Very inefficient but ok for occasional use.

func (*Dict) Get

func (self *Dict) Get(key string) (interface{}, bool)

func (*Dict) GetBool

func (self *Dict) GetBool(key string) (bool, bool)

func (*Dict) GetDefault

func (self *Dict) GetDefault() interface{}

func (*Dict) GetInt64

func (self *Dict) GetInt64(key string) (int64, bool)

func (*Dict) GetString

func (self *Dict) GetString(key string) (string, bool)

func (*Dict) GetStrings

func (self *Dict) GetStrings(key string) ([]string, bool)

func (*Dict) IsCaseInsensitive

func (self *Dict) IsCaseInsensitive() bool

func (*Dict) Keys

func (self *Dict) Keys() []string

func (*Dict) Len

func (self *Dict) Len() int

func (*Dict) MergeFrom

func (self *Dict) MergeFrom(other *Dict)

func (*Dict) Set

func (self *Dict) Set(key string, value interface{}) *Dict

func (*Dict) SetCaseInsensitive

func (self *Dict) SetCaseInsensitive() *Dict

func (*Dict) SetDefault

func (self *Dict) SetDefault(value interface{}) *Dict

func (*Dict) ToDict

func (self *Dict) ToDict() *map[string]interface{}

func (*Dict) Update

func (self *Dict) Update(key string, value interface{}) *Dict

Like Set() but does not effect the order.

Jump to

Keyboard shortcuts

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