hashmap

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 6 Imported by: 1

Documentation

Overview

DigiStratum GoLib - HashMap

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HashMap

type HashMap struct {
	// contains filtered or unexported fields
}

func NewHashMap

func NewHashMap() *HashMap

func NewHashMapFromJsonFile

func NewHashMapFromJsonFile(jsonFile string) (*HashMap, error)

func NewHashMapFromJsonString

func NewHashMapFromJsonString(json *string) (*HashMap, error)

func (*HashMap) Copy

func (r *HashMap) Copy() *HashMap

Get a full (deep) copy of this HashMap This is so that we can give away a copy to someone else without allowing them to tamper with us ref: https://developer20.com/be-aware-of-coping-in-go/

func (*HashMap) Drop

func (r *HashMap) Drop(key string) *HashMap

Drop a single key from the hashmap, if it's set

func (*HashMap) DropAll

func (r *HashMap) DropAll()

Drop all keys/values (reset to empty state)

func (*HashMap) DropSet

func (r *HashMap) DropSet(keys *[]string) *HashMap

Drop an set of keys from the hashmap, if any are set

func (*HashMap) Get

func (r *HashMap) Get(key string) *string

Get a single data element by key name

func (*HashMap) GetBool

func (r *HashMap) GetBool(key string) bool

Get a single data element by key name as a boolean

func (*HashMap) GetInt64

func (r *HashMap) GetInt64(key string) *int64

Get a single data element by key name as an int64

func (*HashMap) GetIterator

func (r *HashMap) GetIterator() func() interface{}

Iterate over all of our items, returning each as a *KeyValuePair in the form of an interface{}

func (*HashMap) GetKeys

func (r *HashMap) GetKeys() []string

Get the set of keys currently loaded into this hashmap

func (*HashMap) GetMissing

func (r *HashMap) GetMissing(keys *[]string) *[]string

Get the list of missing keys according to HasAll()

func (*HashMap) GetSubset

func (r *HashMap) GetSubset(keys *[]string) *HashMap

Make a new hashmap from a subset of the key-values from this one

func (*HashMap) Has

func (r *HashMap) Has(key string) bool

Check whether we have a data element by key name

func (*HashMap) HasAll

func (r *HashMap) HasAll(keys ...string) bool

Check whether we have configuration elements for all the key names

func (*HashMap) IsEmpty

func (r *HashMap) IsEmpty() bool

Check whether this HashMap is empty (has no properties)

func (*HashMap) LoadFromJsonFile

func (r *HashMap) LoadFromJsonFile(jsonFile string) error

Load our hash map with JSON data from a file (or return an error)

func (*HashMap) LoadFromJsonString

func (r *HashMap) LoadFromJsonString(jsonStr *string) error

Load our hash map with JSON data from a string (or return an error)

func (*HashMap) MarshalJSON

func (r *HashMap) MarshalJSON() ([]byte, error)

func (*HashMap) Merge

func (r *HashMap) Merge(mergeHash HashMapIfc)

Merge some additional data on top of our own

func (*HashMap) Set

func (r *HashMap) Set(key, value string)

Set a single data element key to the specified value

func (*HashMap) Size

func (r *HashMap) Size() int

Get the number of properties in this HashMap

func (*HashMap) ToJson

func (r *HashMap) ToJson() (*string, error)

func (*HashMap) ToLog

func (r *HashMap) ToLog(logger log.LoggerIfc, level log.LogLevel, label string)

Dump JSON-like representation of our entries in readable form to supplied logger

func (*HashMap) UnmarshalJSON

func (r *HashMap) UnmarshalJSON(value []byte) error

type HashMapIfc

type HashMapIfc interface {
	Copy() *HashMap
	LoadFromJsonString(jsonStr *string) error
	LoadFromJsonFile(jsonFile string) error
	IsEmpty() bool
	Size() int
	Merge(mergeHash HashMapIfc)
	Set(key, value string)
	Get(key string) *string
	GetInt64(key string) *int64
	GetBool(key string) bool
	GetKeys() []string
	Has(key string) bool
	HasAll(keys ...string) bool
	GetMissing(keys *[]string) *[]string
	GetSubset(keys *[]string) *HashMap
	Drop(key string) *HashMap
	DropSet(keys *[]string) *HashMap
	DropAll()
	GetIterator() func() interface{}
	ToJson() (*string, error)
	ToLog(logger log.LoggerIfc, level log.LogLevel, label string)
}

HashMap public interface

type KeyValuePair

type KeyValuePair struct {
	Key   string
	Value string
}

Jump to

Keyboard shortcuts

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