dictpool

package
v2.34.0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2022 License: MIT, Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReleaseDict

func ReleaseDict(d *Dict)

ReleaseDict release dict.

Types

type Dict

type Dict struct {
	// D slice of KV for storage the data
	D []KV

	// Use binary search to the get an item.
	// It's only useful on big heaps.
	//
	// WARNING: Increase searching performance on big heaps,
	// but whe set new items could be slowier due to the sorting.
	BinarySearch bool
}

Dict dictionary as slice with better performance.

func AcquireDict

func AcquireDict() *Dict

AcquireDict acquire new dict.

func (*Dict) DecodeMsg

func (z *Dict) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Dict) Del

func (d *Dict) Del(key string)

Del delete key.

func (*Dict) DelBytes

func (d *Dict) DelBytes(key []byte)

DelBytes delete key.

func (*Dict) EncodeMsg

func (z *Dict) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Dict) Get

func (d *Dict) Get(key string) interface{}

Get get data from key.

func (*Dict) GetBytes

func (d *Dict) GetBytes(key []byte) interface{}

GetBytes get data from key.

func (*Dict) Has

func (d *Dict) Has(key string) bool

Has check if key exists.

func (*Dict) HasBytes

func (d *Dict) HasBytes(key []byte) bool

HasBytes check if key exists.

func (*Dict) Len

func (d *Dict) Len() int

Len is the number of elements in the Dict.

func (*Dict) Less

func (d *Dict) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j.

func (*Dict) Map

func (d *Dict) Map(dst DictMap)

Map convert to map.

func (*Dict) MarshalMsg

func (z *Dict) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Dict) Msgsize

func (z *Dict) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Dict) Parse

func (d *Dict) Parse(src DictMap)

Parse convert map to Dict.

func (*Dict) Reset

func (d *Dict) Reset()

Reset reset dict.

func (*Dict) Set

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

Set set new key.

func (*Dict) SetBytes

func (d *Dict) SetBytes(key []byte, value interface{})

SetBytes set new key.

func (*Dict) Swap

func (d *Dict) Swap(i, j int)

Swap swaps the elements with indexes i and j.

func (*Dict) UnmarshalMsg

func (z *Dict) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type DictMap

type DictMap map[string]interface{}

DictMap dictionary as map.

func (*DictMap) DecodeMsg

func (z *DictMap) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (DictMap) EncodeMsg

func (z DictMap) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (DictMap) MarshalMsg

func (z DictMap) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (DictMap) Msgsize

func (z DictMap) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*DictMap) UnmarshalMsg

func (z *DictMap) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type KV

type KV struct {
	Key   string
	Value interface{}
}

KV struct so it storages key/value data.

func (*KV) DecodeMsg

func (z *KV) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (KV) EncodeMsg

func (z KV) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (KV) MarshalMsg

func (z KV) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (KV) Msgsize

func (z KV) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*KV) UnmarshalMsg

func (z *KV) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

Jump to

Keyboard shortcuts

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