Documentation ¶
Overview ¶
Package empty provides checks for empty variables.
Index ¶
- func IsEmpty(value interface{}) bool
- func IsNil(value interface{}) bool
- type StrAnyMap
- func (m *StrAnyMap) Clear()
- func (m *StrAnyMap) Clone() *StrAnyMap
- func (m *StrAnyMap) Contains(key string) bool
- func (m *StrAnyMap) FilterEmpty()
- func (m *StrAnyMap) Get(key string) (value interface{})
- func (m *StrAnyMap) GetOrSet(key string, value interface{}) interface{}
- func (m *StrAnyMap) GetOrSetFunc(key string, f func() interface{}) interface{}
- func (m *StrAnyMap) GetOrSetFuncLock(key string, f func() interface{}) interface{}
- func (m *StrAnyMap) IsEmpty() bool
- func (m *StrAnyMap) Iterator(f func(k string, v interface{}) bool)
- func (m *StrAnyMap) Keys() []string
- func (m *StrAnyMap) LockFunc(f func(m map[string]interface{}))
- func (m *StrAnyMap) Map() map[string]interface{}
- func (m *StrAnyMap) MapCopy() map[string]interface{}
- func (m *StrAnyMap) MapStrAny() map[string]interface{}
- func (m *StrAnyMap) MarshalJSON() ([]byte, error)
- func (m *StrAnyMap) Merge(other *StrAnyMap)
- func (m *StrAnyMap) Pop() (key string, value interface{})
- func (m *StrAnyMap) Pops(size int) map[string]interface{}
- func (m *StrAnyMap) RLockFunc(f func(m map[string]interface{}))
- func (m *StrAnyMap) Remove(key string) (value interface{})
- func (m *StrAnyMap) Removes(keys []string)
- func (m *StrAnyMap) Replace(data map[string]interface{})
- func (m *StrAnyMap) Search(key string) (value interface{}, found bool)
- func (m *StrAnyMap) Set(key string, val interface{})
- func (m *StrAnyMap) SetIfNotExist(key string, value interface{}) bool
- func (m *StrAnyMap) SetIfNotExistFunc(key string, f func() interface{}) bool
- func (m *StrAnyMap) SetIfNotExistFuncLock(key string, f func() interface{}) bool
- func (m *StrAnyMap) Sets(data map[string]interface{})
- func (m *StrAnyMap) Size() int
- func (m *StrAnyMap) UnmarshalJSON(b []byte) error
- func (m *StrAnyMap) Values() []interface{}
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type StrAnyMap ¶
type StrAnyMap struct {
// contains filtered or unexported fields
}
func NewStrAnyMap ¶
NewStrAnyMap returns an empty StrAnyMap object. The parameter <safe> is used to specify whether using map in concurrent-safety, which is false in default.
func NewStrAnyMapFrom ¶
NewStrAnyMapFrom creates and returns a hash map from given map <data>. Note that, the param <data> map will be set as the underlying data map(no deep copy), there might be some concurrent-safe issues when changing the map outside.
func (*StrAnyMap) Clear ¶
func (m *StrAnyMap) Clear()
Clear deletes all data of the map, it will remake a new underlying data map.
func (*StrAnyMap) Contains ¶
Contains checks whether a key exists. It returns true if the <key> exists, or else false.
func (*StrAnyMap) FilterEmpty ¶
func (m *StrAnyMap) FilterEmpty()
FilterEmpty deletes all key-value pair of which the value is empty.
func (*StrAnyMap) GetOrSet ¶
GetOrSet returns the value by key, or sets value with given <value> if it does not exist and then returns this value.
func (*StrAnyMap) GetOrSetFunc ¶
GetOrSetFunc returns the value by key, or sets value with returned value of callback function <f> if it does not exist and then returns this value.
func (*StrAnyMap) GetOrSetFuncLock ¶
GetOrSetFuncLock returns the value by key, or sets value with returned value of callback function <f> if it does not exist and then returns this value.
GetOrSetFuncLock differs with GetOrSetFunc function is that it executes function <f> with mutex.Lock of the hash map.
func (*StrAnyMap) IsEmpty ¶
IsEmpty checks whether the map is empty. It returns true if map is empty, or else false.
func (*StrAnyMap) Iterator ¶
Iterator iterates the hash map readonly with custom callback function <f>. If <f> returns true, then it continues iterating; or false to stop.
func (*StrAnyMap) LockFunc ¶
LockFunc locks writing with given callback function <f> within RWMutex.Lock.
func (*StrAnyMap) Map ¶
Map returns the underlying data map. Note that, if it's in concurrent-safe usage, it returns a copy of underlying data, or else a pointer to the underlying data.
func (*StrAnyMap) MapStrAny ¶
MapStrAny returns a copy of the underlying data of the map as map[string]interface{}.
func (*StrAnyMap) MarshalJSON ¶
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*StrAnyMap) Merge ¶
Merge merges two hash maps. The <other> map will be merged into the map <m>.
func (*StrAnyMap) Pops ¶
Pops retrieves and deletes <size> items from the map. It returns all items if size == -1.
func (*StrAnyMap) RLockFunc ¶
RLockFunc locks reading with given callback function <f> within RWMutex.RLock.
func (*StrAnyMap) Remove ¶
Remove deletes value from map by given <key>, and return this deleted value.
func (*StrAnyMap) Search ¶
Search searches the map with given <key>. Second return parameter <found> is true if key was found, otherwise false.
func (*StrAnyMap) SetIfNotExist ¶
SetIfNotExist sets <value> to the map if the <key> does not exist, and then returns true. It returns false if <key> exists, and <value> would be ignored.
func (*StrAnyMap) SetIfNotExistFunc ¶
SetIfNotExistFunc sets value with return value of callback function <f>, and then returns true. It returns false if <key> exists, and <value> would be ignored.
func (*StrAnyMap) SetIfNotExistFuncLock ¶
SetIfNotExistFuncLock sets value with return value of callback function <f>, and then returns true. It returns false if <key> exists, and <value> would be ignored.
SetIfNotExistFuncLock differs with SetIfNotExistFunc function is that it executes function <f> with mutex.Lock of the hash map.
func (*StrAnyMap) UnmarshalJSON ¶
UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.