Help us shape the future of Go! Take the 2026 Go Developer Survey

ordereddict

package module
v0.0.0-...-6857b08 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 11 Imported by: 218

README

ordereddict

A simple Ordered Dict implementation.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Mark the item as deleted
	Deleted = 1

	CompactionThreashold = 10

	// Keep stats about compactions - mostly used for tests
	Compactions uint64
)

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 concerete implementation of a row - similar to Python's OrderedDict. Main difference is that delete is implemented by recording a deletion - this means it is slightly less memory efficient to delete as we expect deletes to be relatively rare.

func GetMap

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

func NewDict

func NewDict() *Dict

func (*Dict) AliasField

func (self *Dict) AliasField(src, dest string) *Dict

func (*Dict) Clear

func (self *Dict) Clear()

Clear the dict

func (*Dict) Copy

func (self *Dict) Copy() *Dict

func (*Dict) DebugString

func (self *Dict) DebugString() string

func (*Dict) Delete

func (self *Dict) Delete(key string)

Mark the item as deleted - we dont expect this to be too often.

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) GoString

func (self *Dict) GoString() string

func (*Dict) IsCaseInsensitive

func (self *Dict) IsCaseInsensitive() bool

func (*Dict) Items

func (self *Dict) Items() []Item

func (*Dict) Keys

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

func (*Dict) Len

func (self *Dict) Len() int

func (*Dict) MarshalJSON

func (self *Dict) MarshalJSON() ([]byte, error)

Preserve key order when marshalling to JSON.

func (*Dict) MarshalYAML

func (self *Dict) MarshalYAML() (interface{}, error)

func (*Dict) MergeFrom

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

func (*Dict) Set

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

Set inserts the value into the dict. This function also reorders the dict to make the new key the latest. If the key is already present, this is equivalent to a Delete() on the old key and an Update(). If the caller calls Set repeatadly on the same key this can result in a lot of compactions. In this case consider using Update() instead.

func (*Dict) SetCaseInsensitive

func (self *Dict) SetCaseInsensitive() *Dict

func (*Dict) SetDefault

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

func (*Dict) String

func (self *Dict) String() string

Printing the dict will always result in a valid JSON document.

func (*Dict) ToMap

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

Convert to Golang native map type (unordered)

func (*Dict) UnmarshalJSON

func (self *Dict) UnmarshalJSON(data []byte) error

this implements type json.Unmarshaler interface, so can be called in json.Unmarshal(data, om). We preserve key order when unmarshaling from JSON.

func (*Dict) UnmarshalYAML

func (self *Dict) UnmarshalYAML(unmarshal func(interface{}) error) error

func (*Dict) Update

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

Like Set() but does not effect the order. This also does not trigger any compactions and is more efficient then Set().

func (*Dict) Values

func (self *Dict) Values() []interface{}

type Item

type Item struct {
	Key   string
	Value interface{}
}

Jump to

Keyboard shortcuts

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