Documentation ¶
Index ¶
- type CMKey
- type CMap
- func (m CMap) Add(v Value) (ok bool)
- func (m CMap) AddAll(from CMap) (conflicting CMKey, success bool)
- func (m CMap) Any(predicate func(Value) bool) (Value, bool)
- func (m CMap) Clone() CMap
- func (m CMap) Filter(predicate func(Value) bool) CMap
- func (m CMap) FilteredSnapshot(predicate func(Value) bool) map[CMKey]Value
- func (m CMap) Get(key CMKey) (v Value, ok bool)
- func (m CMap) GetAll() map[CMKey]Value
- func (m CMap) Keys() []CMKey
- func (m CMap) Len() int
- func (m CMap) Merge(other CMap) CMap
- func (m CMap) MustAdd(v Value)
- func (m CMap) Remove(key CMKey)
- func (m CMap) Set(key CMKey, value Value)
- func (m *CMap) SetAll(v map[CMKey]Value)
- func (m CMap) Single(predicate func(Value) bool) (Value, bool)
- func (m CMap) Snapshot() map[CMKey]Value
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CMap ¶
type CMap struct {
// contains filtered or unexported fields
}
CMap is a wrapper around map[CMKey]Value which is safe for concurrent read and write.
func NewCMap ¶
NewCMap creates a new CMap. You may optionally pass any number of Values, which will be added to this map.
func NewCMapFromMap ¶
NewCMapFromMap creates a new CMap. You may optionally pass any number of map[CMKey]Values, which will be merged key-wise into the new CMap, with keys from the right-most map taking precedence.
func (CMap) Add ¶
Add adds a (k, v) pair into a map if it is not already there. Returns true if the value was added, false if not.
func (CMap) AddAll ¶
AddAll returns (zero CMKey, true) if all entries from the passed in CMap have different keys and all are added to this CMap. If any of the keys conflict, nothing will be added to this CMap and AddAll will return the conflicting CMKey and false.
func (CMap) Any ¶
Any returns (a single Value matching predicate, true), if there are any Values matching predicate in CMap. Otherwise returns (zero Value, false).
func (CMap) Filter ¶
Filter returns a new CMap containing only the entries where the predicate returns true for the given value. A nil predicate is equivalent to calling Clone.
func (CMap) FilteredSnapshot ¶
FilteredSnapshot returns a moment-in-time filtered copy of the current underlying map[CMKey]Value. (CMKey, Value) pairs are included if they satisfy predicate.
func (CMap) Merge ¶
Merge returns a new CMap with all entries from this CMap and the other. If any keys in other match keys in this *CMap, keys from other will appear in the returned *CMap.
func (*CMap) SetAll ¶
SetAll sets the internal map (it allows hy to unmarshal CMap). Note: SetAll is the only method that is not safe for concurrent access.