Documentation ¶
Overview ¶
Package treemap implements a map backed by red-black Tree.
Elements are ordered by key in the map.
Structure is not thread safe.
Index ¶
- Variables
- type Iterator
- type K
- type Map
- func (m *Map) Begin() Iterator
- func (m *Map) Each(f func(key K, value V))
- func (m *Map) End() Iterator
- func (m *Map) Find(f func(key K, value V) bool) (k K, v V)
- func (m *Map) Get(key K) Iterator
- func (m *Map) Insert(key K, value V) Iterator
- func (m *Map) Iterator() Iterator
- func (m *Map) Keys() []K
- func (m *Map) LowerBound(key K) Iterator
- func (m Map) MarshalJSON() ([]byte, error)
- func (m Map) Pack() (re []byte, err error)
- func (m *Map) Put(key K, value V)
- func (m *Map) Remove(key K)
- func (m Map) String() string
- func (m *Map) UnmarshalJSON(data []byte) error
- func (m *Map) Unpack(in []byte) (int, error)
- func (m *Map) UpperBound(key K) Iterator
- func (m *Map) Values() []V
- type V
Constants ¶
This section is empty.
Variables ¶
var Compare = func(a, b interface{}) int { return container.IntComparator(a.(int), b.(int)) }
var Multi = false
Functions ¶
This section is empty.
Types ¶
type Iterator ¶
Iterator holding the Iterator's state
type Map ¶
Map holds the elements in a red-black Tree
func (*Map) Begin ¶
Begin returns First Iterator whose position points to the first element Return End Iterator when the map is empty
func (*Map) Each ¶
Each calls the given function once for each element, passing that element's key and value.
func (*Map) Find ¶
Find passes each element of the container to the given function and returns the first (key,value) for which the function is true or nil,nil otherwise if no element matches the criteria.
func (*Map) Get ¶
Get searches the element in the map by key and returns its value or nil if key is not found in Tree. Second return parameter is true if key was found, otherwise false. Key should adhere to the comparator's type assertion, otherwise method panics.
func (*Map) LowerBound ¶
func (Map) MarshalJSON ¶
func (*Map) Put ¶
Put inserts key-value pair into the map. Key should adhere to the comparator's type assertion, otherwise method panics.
func (*Map) Remove ¶
Remove removes the element from the map by key. Key should adhere to the comparator's type assertion, otherwise method panics.
func (*Map) UnmarshalJSON ¶
FromJSON populates the map from the input JSON representation.