Documentation ¶
Overview ¶
Package treemap implements a tree map to store key-value pairs in sorted key order.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cmp ¶
type Cmp func(k1, k2 interface{}) int
Cmp represents the compare function for two keys. Return -1 if k1 < k2, 1 if k1 > k2, 0 if k1 == k2.
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map implements a map (backed by a red-black tree) that stores key-value pairs in sorted key order. It supports arbitrary types as keys and values as long as a compare function for keys is provided. Methods of the map are not thread-safe.
func (*Map) Get ¶
Get returns the value associated with key, or nil if key is not found. The second return value found is set to true if key is found, and false otherwise.
func (*Map) Keys ¶
func (m *Map) Keys() []interface{}
Keys returns a copy of all keys in the map in ascending order.
func (*Map) Put ¶
func (m *Map) Put(key interface{}, value interface{})
Put adds a key-value pair to the map. If key exists, the associated value is updated to the new value. Otherwise, a new key-value pair is added.