Documentation
¶
Overview ¶
Package tinymap provides a simple to use interface that behaves like a HashMap.
Multiple Maps are exposed for use as well as structs that behave like Tuples.
This package is intended to be used with tinygo.
However it has some nice little structs, so feel free to use this as you wish.
It is very small, but helps with embedded programming.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ByteMap ¶
type ByteMap struct {
// Data is public but use carefully :)
Data []ByteTuple
}
ByteMap stores ByteTuples
It behaves like a HashMap!
byteMap := new(ByteMap)
byteMap.Set([]byte("42"), []byte("9000"))
val, err := byteMap.Get([]byte("42"))
if err != nil {
log.Print(err)
}
fmt.Print(val)
byteMap.Delete([]byte("42"))
func (*ByteMap) Delete ¶
Delete removes Tuples. Returns true if deleted. Returns false if the key was not found.
type IntMap ¶
type IntMap struct {
// Data is public but use carefully :)
Data []IntTuple
}
IntMap stores IntTuples
It behaves like a HashMap!
intMap := new(IntMap)
intMap.Set(42, 9000)
val, err := intMap.Get(42)
if err != nil {
log.Print(err)
}
fmt.Print(val)
intMap.Delete(42)
func (*IntMap) Delete ¶
Delete removes Tuples. Returns true if deleted. Returns false if the key was not found.
type IntStrMap ¶
type IntStrMap struct {
// Data is public but use carefully :)
Data []IntStrTuple
}
IntStrMap stores IntStrTuples
It behaves like a HashMap!
intStrMap := new(IntStrMap)
intStrMap.Set(42, "9000")
val, err := intStrMap.Get(42)
if err != nil {
log.Print(err)
}
fmt.Print(val)
intStrMap.Delete(42)
func (*IntStrMap) Delete ¶
Delete removes Tuples. Returns true if deleted. Returns false if the key was not found.
type StrByteMap ¶
type StrByteMap struct {
// Data is public but use carefully :)
Data []StrByteTuple
}
StrByteMap stores StrByteTuples
It behaves like a HashMap!
strByteMap := new(StrByteMap)
strByteMap.Set("foo", []byte("bar"))
val, err := strByteMap.Get("foo")
if err != nil {
log.Print(err)
}
fmt.Print(val)
strByteMap.Delete("foo")
func (*StrByteMap) Delete ¶
func (t *StrByteMap) Delete(key string) bool
Delete removes Tuples. Returns true if deleted. Returns false if the key was not found.
func (StrByteMap) Get ¶
func (t StrByteMap) Get(key string) ([]byte, error)
Get fetches Tuples by Key and returns their Val
func (*StrByteMap) Set ¶
func (t *StrByteMap) Set(key string, val []byte)
Set will update or add Tuples. If StrByteTuple.Key already exists, only the StrByteTuple.Val is updated. Otherwise a new StrByteTuple is inserted into the Data slice.
type StrMap ¶
type StrMap struct {
// Data is public but use carefully :)
Data []StrTuple
}
StrMap stores StrTuples
It behaves like a HashMap!
strMap := new(StrMap)
strMap.Set("foo", "bar")
val, err := strMap.Get("foo")
if err != nil {
log.Print(err)
}
fmt.Print(val)
strMap.Delete("foo")
func (*StrMap) Delete ¶
Delete removes Tuples. Returns true if deleted. Returns false if the key was not found.