Documentation
¶
Index ¶
- Variables
- func DeepCopyValue(smfvalue interface{}, force bool) interface{}
- func DeepMerge(smt SortedMap, smf SortedMap, force bool)
- func DeepMergeValue(smtvalue interface{}, smfvalue interface{}, force bool) interface{}
- func Int64Compare(a, b int64) int
- func IntCompare(a, b int) int
- func KeyCompare(a, b interface{}) int
- func MapItemCompare(a, b interface{}) int
- func MarshalJSON(sm SortedMap) (rbs []byte, err error)
- func Merge(smt Map, smf Map)
- func MergeMap(smt Map, smfmap interface{})
- func NewRedBlackTree(compare Compare) *redBlackTree
- func StringCompare(a, b string) int
- func ToMap(smf Map) map[interface{}]interface{}
- func ToStringMap(smf Map) map[string]interface{}
- func UnmarshalJSON(sm SortedMap, bs []byte) (err error)
- type Compare
- type Element
- type Item
- type ItemVisitor
- type JSONFormatError
- type LinkedMap
- func (m *LinkedMap) Clear()
- func (m *LinkedMap) Copy() SortedMap
- func (m *LinkedMap) DeepCopy() SortedMap
- func (m *LinkedMap) Delete(key interface{}) (didDelete bool)
- func (m *LinkedMap) Fetch(p func(key interface{}, value interface{}) bool)
- func (m *LinkedMap) FetchRange(from interface{}, to interface{}, ...)
- func (m *LinkedMap) FetchReverse(p func(key interface{}, value interface{}) bool)
- func (m *LinkedMap) First() *Element
- func (m *LinkedMap) FirstItem() *MapItem
- func (m *LinkedMap) Get(key interface{}, defaultValue ...interface{}) (interface{}, bool)
- func (m *LinkedMap) GetElement(key interface{}) *Element
- func (m *LinkedMap) GetValue(key interface{}, defaultValue ...interface{}) interface{}
- func (m *LinkedMap) Has(key interface{}) bool
- func (m *LinkedMap) Keys() (keys []interface{})
- func (m *LinkedMap) Last() *Element
- func (m *LinkedMap) LastItem() *MapItem
- func (m *LinkedMap) Len() int
- func (m *LinkedMap) MarshalJSON() ([]byte, error)
- func (m *LinkedMap) Put(key, value interface{}) bool
- func (m *LinkedMap) PutAll(amap interface{}) SortedMap
- func (m *LinkedMap) String() string
- func (m *LinkedMap) UnmarshalJSON(bs []byte) (err error)
- func (m *LinkedMap) Values() (values []interface{})
- type Map
- type MapItem
- type Node
- type SortedMap
- type Treap
- func (t *Treap) Delete(target Item) *Treap
- func (t *Treap) Get(target Item) Item
- func (t *Treap) Max() Item
- func (t *Treap) Min() Item
- func (t *Treap) Upsert(item Item, itemPriority int) *Treap
- func (t *Treap) VisitAscend(pivot Item, visitor ItemVisitor)
- func (t *Treap) VisitDescend(pivot Item, visitor ItemVisitor)
- type TreapMap
- func (m *TreapMap) Clear()
- func (m *TreapMap) Copy() SortedMap
- func (m *TreapMap) DeepCopy() SortedMap
- func (m *TreapMap) Delete(key interface{}) (didDeleted bool)
- func (m *TreapMap) Fetch(p func(key interface{}, value interface{}) bool)
- func (m *TreapMap) FetchRange(from interface{}, to interface{}, ...)
- func (m *TreapMap) FetchReverse(p func(key interface{}, value interface{}) bool)
- func (m *TreapMap) FirstItem() *MapItem
- func (m *TreapMap) Get(key interface{}, defaultValue ...interface{}) (interface{}, bool)
- func (m *TreapMap) GetValue(key interface{}, defaultValue ...interface{}) interface{}
- func (m *TreapMap) Has(key interface{}) bool
- func (m *TreapMap) Keys() []interface{}
- func (m *TreapMap) LastItem() *MapItem
- func (m *TreapMap) Len() int
- func (m *TreapMap) MarshalJSON() ([]byte, error)
- func (m *TreapMap) Put(key interface{}, value interface{}) bool
- func (m *TreapMap) PutAll(amap interface{}) SortedMap
- func (m *TreapMap) String() string
- func (m *TreapMap) UnmarshalJSON(bs []byte) (err error)
- func (m *TreapMap) Values() []interface{}
- type TreeMap
- func (m *TreeMap) Clear()
- func (m *TreeMap) Copy() SortedMap
- func (m *TreeMap) DeepCopy() SortedMap
- func (m *TreeMap) Delete(key interface{}) (didDeleted bool)
- func (m *TreeMap) Fetch(p func(key interface{}, value interface{}) bool)
- func (m *TreeMap) FetchRange(from interface{}, to interface{}, ...)
- func (m *TreeMap) FetchReverse(p func(key interface{}, value interface{}) bool)
- func (m *TreeMap) FirstItem() *MapItem
- func (m *TreeMap) Get(key interface{}, defaultValue ...interface{}) (interface{}, bool)
- func (m *TreeMap) GetValue(key interface{}, defaultValue ...interface{}) interface{}
- func (m *TreeMap) Has(key interface{}) bool
- func (m *TreeMap) Keys() []interface{}
- func (m *TreeMap) LastItem() *MapItem
- func (m *TreeMap) Len() int
- func (m *TreeMap) MarshalJSON() ([]byte, error)
- func (m *TreeMap) Put(key interface{}, value interface{}) bool
- func (m *TreeMap) PutAll(amap interface{}) SortedMap
- func (m *TreeMap) String() string
- func (m *TreeMap) UnmarshalJSON(bs []byte) (err error)
- func (m *TreeMap) Values() []interface{}
Constants ¶
This section is empty.
Variables ¶
var JSONParserError = fmt.Errorf("parser error")
Functions ¶
func DeepCopyValue ¶
func DeepCopyValue(smfvalue interface{}, force bool) interface{}
force 强制合并不同子类型的 slice,map 为 []interface{},LinkedMap[interface{}]interface{} 涉及深度 map 的并发,应用需自行处理同步控制问题
func DeepMerge ¶
force 强制合并不同子类型的 slice,map 为 []interface{},LinkedMap[interface{}]interface{} 涉及深度 map 的并发,应用需自行处理同步控制问题
func DeepMergeValue ¶
func DeepMergeValue(smtvalue interface{}, smfvalue interface{}, force bool) interface{}
force 强制合并不同子类型的 slice,map 为 []interface{},LinkedMap[interface{}]interface{} 涉及深度 map 的并发,应用需自行处理同步控制问题
func Int64Compare ¶
func IntCompare ¶
func KeyCompare ¶
func KeyCompare(a, b interface{}) int
func MapItemCompare ¶
func MapItemCompare(a, b interface{}) int
func MarshalJSON ¶
func NewRedBlackTree ¶
func NewRedBlackTree(compare Compare) *redBlackTree
func StringCompare ¶
func ToStringMap ¶
func UnmarshalJSON ¶
Types ¶
type Compare ¶
type Compare func(a, b interface{}) int
Compare returns an integer comparing the two items lexicographically. The result will be 0 if a==b, -1 if a < b, and +1 if a > b. likly return a - b
type Element ¶
type Element struct {
// contains filtered or unexported fields
}
type ItemVisitor ¶
ItemVistor callback should return true to keep going on the visitation.
type JSONFormatError ¶
func (*JSONFormatError) Error ¶
func (jfe *JSONFormatError) Error() string
type LinkedMap ¶
func NewLinkedMap ¶
func NewLinkedMap() *LinkedMap
func ToLinkedMap ¶
func ToLinkedMap(amap map[interface{}]interface{}) *LinkedMap
func (*LinkedMap) Delete ¶
Delete will remove a key from the map. It will return true if the key was removed (the key did exist).
func (*LinkedMap) FetchRange ¶
func (*LinkedMap) FetchReverse ¶
func (*LinkedMap) First ¶
First will return the element that is the first (oldest Set element). If there are no elements this will return nil.
func (*LinkedMap) Get ¶
Get returns the value for a key. If the key does not exist, the second return parameter will be false and the value will be nil or defaultValue.
func (*LinkedMap) GetElement ¶
GetElement returns the element for a key. If the key does not exist, the pointer will be nil.
func (*LinkedMap) GetValue ¶
func (m *LinkedMap) GetValue(key interface{}, defaultValue ...interface{}) interface{}
func (*LinkedMap) Keys ¶
func (m *LinkedMap) Keys() (keys []interface{})
Keys returns all of the keys in the order they were inserted. If a key was replaced it will retain the same position. To ensure most recently set keys are always at the end you must always Delete before Set.
func (*LinkedMap) Last ¶
Last will return the element that is the last (most recent Set element). If there are no elements this will return nil.
func (*LinkedMap) MarshalJSON ¶
func (*LinkedMap) Put ¶
Put will set (or replace) a value for a key. If the key was new, then true will be returned. The returned value will be false if the value was replaced (even if the value was the same).
func (*LinkedMap) UnmarshalJSON ¶
type Map ¶
type Map interface {
// Put will set (or replace) a value for a key. If the key was new, then true
// will be returned. The returned value will be false if the value was replaced
// (even if the value was the same).
Put(key interface{}, value interface{}) bool
Delete(key interface{}) bool
Get(key interface{}, defaultValue ...interface{}) (interface{}, bool)
GetValue(key interface{}, defaultValue ...interface{}) interface{}
Has(key interface{}) bool
Len() int
Keys() []interface{}
Values() []interface{}
Fetch(p func(key interface{}, value interface{}) bool)
}
type SortedMap ¶
type SortedMap interface {
Map
//
Copy() SortedMap
// 深层复制,所有 slice,map,及所有实现了 DeepCopy 接口函数的数据 都将被递归复制
DeepCopy() SortedMap
// 参数 amap 只能是 map 或 SortedMap 类型, 为初始化使用方便返回当前对象自身
PutAll(amap interface{}) SortedMap
Clear()
FirstItem() *MapItem
LastItem() *MapItem
FetchReverse(p func(key interface{}, value interface{}) bool)
FetchRange(from interface{}, to interface{}, p func(key interface{}, value interface{}) bool, reverse bool)
//
UnmarshalJSON(bs []byte) (err error)
MarshalJSON() ([]byte, error)
String() string
}
type Treap ¶
type Treap struct {
// contains filtered or unexported fields
}
func (*Treap) Upsert ¶
Note: only the priority of the first insert of an item is used. Priorities from future updates on already existing items are ignored. To change the priority for an item, you need to do a Delete then an Upsert.
func (*Treap) VisitAscend ¶
func (t *Treap) VisitAscend(pivot Item, visitor ItemVisitor)
Visit items greater-than-or-equal to the pivot, in ascending order.
func (*Treap) VisitDescend ¶
func (t *Treap) VisitDescend(pivot Item, visitor ItemVisitor)
Visit items less-than-or-equal to the pivot, in descending order.
type TreapMap ¶
func NewTreapMap ¶
func NewTreapMap() *TreapMap
func ToTreapMap ¶
func ToTreapMap(amap map[interface{}]interface{}) *TreapMap
func (*TreapMap) FetchRange ¶
func (*TreapMap) FetchReverse ¶
func (*TreapMap) GetValue ¶
func (m *TreapMap) GetValue(key interface{}, defaultValue ...interface{}) interface{}
func (*TreapMap) MarshalJSON ¶
func (*TreapMap) UnmarshalJSON ¶
type TreeMap ¶
func NewTreeMap ¶
func NewTreeMap() *TreeMap
func (*TreeMap) FetchRange ¶
func (*TreeMap) FetchReverse ¶
func (*TreeMap) GetValue ¶
func (m *TreeMap) GetValue(key interface{}, defaultValue ...interface{}) interface{}