Documentation ¶
Index ¶
- func Less(v1, v2 interface{}) bool
- func Sort(s []map[string]interface{}, key string, aes bool)
- func SortStr(s []map[string]string, key string, aes bool)
- func ToAny(a map[string]string) (b map[string]interface{})
- func ToString(a map[string]interface{}) (b map[string]string)
- type M
- type Map
- func (s *Map) Clear()
- func (s *Map) Clone() *Map
- func (s *Map) CloneAndClear() *Map
- func (s *Map) Delete(key interface{})
- func (s *Map) GC()
- func (s *Map) IndexOf(k interface{}) int
- func (s *Map) IsEmpty() bool
- func (s *Map) Keys() (keys []interface{})
- func (s *Map) Len() int
- func (s *Map) Load(key interface{}) (value interface{}, ok bool)
- func (s *Map) LoadAndDelete(key interface{}) (value interface{}, loaded bool)
- func (s *Map) LoadAndStoreFunc(key interface{}, ...) (newValue interface{}, loaded bool)
- func (s *Map) LoadAndStoreFuncErr(key interface{}, ...) (newValue interface{}, loaded bool, err error)
- func (s *Map) LoadOrStore(key, value interface{}) (actual interface{}, loaded bool)
- func (s *Map) LoadOrStoreFront(key, value interface{}) (actual interface{}, loaded bool)
- func (s *Map) LoadOrStoreFunc(key interface{}, f func() interface{}) (actual interface{}, loaded bool)
- func (s *Map) LoadOrStoreFuncErr(key interface{}, f func() (x interface{}, err error)) (actual interface{}, loaded bool, err error)
- func (s *Map) Merge(m *Map) *Map
- func (s *Map) MergeMap(m Mii) *Map
- func (s *Map) MergeStrMap(m M) *Map
- func (s *Map) MergeStrStrMap(m Mss) *Map
- func (s *Map) MergeSyncMap(m *sync.Map) *Map
- func (s *Map) Pop() (k, v interface{}, ok bool)
- func (s *Map) Range(f func(key, value interface{}) bool)
- func (s *Map) RangeFast(f func(key, value interface{}) bool)
- func (s *Map) Shift() (k, v interface{}, ok bool)
- func (s *Map) Store(key, value interface{})
- func (s *Map) StoreFront(key, value interface{})
- func (s *Map) String() string
- func (s *Map) StringKeys() (keys []string)
- func (s *Map) ToMap() map[interface{}]interface{}
- func (s *Map) ToStringMap() map[string]interface{}
- type Mii
- type Mss
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map a map can kept the sequence of keys when range the map have more useful function, Len(), Shift(), Pop(),Keys(), etc.
func (*Map) IndexOf ¶
IndexOf indicates the index of value in Map s, if not found returns -1.
idx start with 0.
func (*Map) Keys ¶
func (s *Map) Keys() (keys []interface{})
Keys returns all keys in map s and keep the sequence of store sequence.
func (*Map) Load ¶
Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.
func (*Map) LoadAndDelete ¶
LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present.
func (*Map) LoadAndStoreFunc ¶
func (s *Map) LoadAndStoreFunc(key interface{}, f func(oldValue interface{}, loaded bool) (newValue interface{})) (newValue interface{}, loaded bool)
LoadAndStoreFunc call the given func and stores it returns value. The loaded result is true if the keys was exists, false if not exists. If loaded, the given func firstly parameter is the loaded value, otherwise is nil.
func (*Map) LoadAndStoreFuncErr ¶
func (s *Map) LoadAndStoreFuncErr(key interface{}, f func(oldValue interface{}, loaded bool) (newValue interface{}, err error)) (newValue interface{}, loaded bool, err error)
LoadAndStoreFuncErr call the given func and stores it returns value, if func returns an error, the error be returned. The loaded result is true if the keys was exists, false if not exists. If loaded, the given func firstly parameter is the loaded value, otherwise is nil.
func (*Map) LoadOrStore ¶
LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored.
func (*Map) LoadOrStoreFront ¶
LoadOrStoreFront returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored. The key will be stored the first in keys queue if key not exists.
func (*Map) LoadOrStoreFunc ¶
func (s *Map) LoadOrStoreFunc(key interface{}, f func() interface{}) (actual interface{}, loaded bool)
LoadOrStoreFunc returns the existing value for the key if present. Otherwise, it call the given func and stores it returns value. The loaded result is true if the value was loaded, false if stored.
func (*Map) LoadOrStoreFuncErr ¶
func (s *Map) LoadOrStoreFuncErr(key interface{}, f func() (x interface{}, err error)) (actual interface{}, loaded bool, err error)
LoadOrStoreFuncErr returns the existing value for the key if present. Otherwise, it call the given func and stores it returns value, if the func returns an error, nothing will be stored, the function's error be returned. The loaded result is true if the value was loaded, false if stored.
func (*Map) MergeStrStrMap ¶
MergeStrStrMap merges a map to Map s.
func (*Map) MergeSyncMap ¶
MergeSyncMap merges a sync.Map to Map s.
func (*Map) Range ¶
Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration.
Range keep the sequence of store sequence.
func (*Map) RangeFast ¶
RangeFast calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration.
RangeFast keep the sequence of store sequence.
RangeFast do not create a snapshot for range, so you can not modify map s in range loop, indicate do not call Delete(), Store(), LoadOrStore(), Merge(), etc.
func (*Map) StoreFront ¶
func (s *Map) StoreFront(key, value interface{})
StoreFront sets the value for a key. The key will be stored the first in keys queue.
func (*Map) StringKeys ¶
StringKeys returns all keys in map s and keep the sequence of store sequence.
func (*Map) ToStringMap ¶
ToStringMap duplicates the map s.