Documentation
¶
Overview ¶
The package tinymap provides functionality of map as slice of key-value pair.
The type TinyMap is copy of "userData" type from github.com/valyala/fasthttp
All credits go to Aliaksandr Valialkin, VertaMedia, Kirill Danshin, Erik Dubbelboer, FastHTTP Authors
Index ¶
- type TinyMap
- func (tm *TinyMap) Get(key string) interface{}
- func (tm *TinyMap) GetBytes(key []byte) interface{}
- func (tm *TinyMap) Reset()
- func (tm *TinyMap) Set(key string, value interface{})
- func (tm *TinyMap) SetBytes(key []byte, value interface{})
- func (tm *TinyMap) VisitValues(visitor func([]byte, interface{}))
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TinyMap ¶
type TinyMap []item
TinyMap is a slice of items, acting as a map.
func (*TinyMap) Get ¶
Get retrieves the value associated with a key. Returns nil if the key does not exist.
func (*TinyMap) GetBytes ¶
GetBytes retrieves the value associated with a byte slice key. It internally converts the byte slice to a string before getting the value.
func (*TinyMap) Reset ¶
func (tm *TinyMap) Reset()
Reset clears the TinyMap by truncating it to zero length. If any value implements io.Closer, it will call the Close method before clearing.
func (*TinyMap) Set ¶
Set adds or updates a key-value pair in the TinyMap. If the key exists, its value is updated. If not, the key-value pair is added.
func (*TinyMap) SetBytes ¶
SetBytes adds or updates a key-value pair using a byte slice as the key. It internally converts the byte slice to a string before setting the value.
func (*TinyMap) VisitValues ¶ added in v0.0.2
VisitValues applies a visitor function to all key-value pairs in the TinyMap. The visitor function receives the key as a byte slice and the value.