Documentation
¶
Index ¶
- type TreeMap
- func (m *TreeMap[K, V]) All(f func(key K, value V) bool) bool
- func (m *TreeMap[K, V]) Any(f func(key K, value V) bool) bool
- func (m *TreeMap[K, V]) Ceiling(key K) (foundKey K, foundValue V, ok bool)
- func (m *TreeMap[K, V]) CeilingOrMax(key K) (foundKey K, foundValue V, ok bool)
- func (m *TreeMap[K, V]) Clear()
- func (m *TreeMap[K, V]) Each(f func(key K, value V))
- func (m *TreeMap[K, V]) Empty() bool
- func (m *TreeMap[K, V]) Find(f func(key K, value V) bool) (k K, v V)
- func (m *TreeMap[K, V]) FindIter(key K) *TreeMapIterator[K, V]
- func (m *TreeMap[K, V]) Floor(key K) (foundKey K, foundValue V, ok bool)
- func (m *TreeMap[K, V]) FloorOrMin(key K) (foundKey K, foundValue V, ok bool)
- func (m *TreeMap[K, V]) FromJSON(data []byte) error
- func (m *TreeMap[K, V]) Get(key K) (value V, found bool)
- func (m *TreeMap[K, V]) Iterator() *TreeMapIterator[K, V]
- func (m *TreeMap[K, V]) Keys() []K
- func (m *TreeMap[K, V]) LowerBound(key K) *TreeMapIterator[K, V]
- func (m *TreeMap[K, V]) Map(f func(key1 K, value1 V) (K, V)) *TreeMap[K, V]
- func (m *TreeMap[K, V]) MarshalJSON() ([]byte, error)
- func (m *TreeMap[K, V]) Max() (key K, value V, ok bool)
- func (m *TreeMap[K, V]) Min() (key K, value V, ok bool)
- func (m *TreeMap[K, V]) Put(key K, value V)
- func (m *TreeMap[K, V]) Range(f func(key K, value V) bool)
- func (m *TreeMap[K, V]) Remove(key K)
- func (m *TreeMap[K, V]) ReverseRange(f func(key K, value V) bool)
- func (m *TreeMap[K, V]) Select(f func(key K, value V) bool) *TreeMap[K, V]
- func (m *TreeMap[K, V]) Size() int
- func (m *TreeMap[K, V]) String() string
- func (m *TreeMap[K, V]) ToJSON() ([]byte, error)
- func (m *TreeMap[K, V]) UnmarshalJSON(bytes []byte) error
- func (m *TreeMap[K, V]) UpperBound(key K) *TreeMapIterator[K, V]
- func (m *TreeMap[K, V]) Values() []V
- type TreeMapIterator
- func (iterator *TreeMapIterator[K, V]) Begin()
- func (iterator *TreeMapIterator[K, V]) End()
- func (iterator *TreeMapIterator[K, V]) First() bool
- func (iterator *TreeMapIterator[K, V]) IsBegin() bool
- func (iterator *TreeMapIterator[K, V]) IsEnd() bool
- func (iterator *TreeMapIterator[K, V]) Key() K
- func (iterator *TreeMapIterator[K, V]) Last() bool
- func (iterator *TreeMapIterator[K, V]) Next() bool
- func (iterator *TreeMapIterator[K, V]) NextTo(f func(key K, value V) bool) bool
- func (iterator *TreeMapIterator[K, V]) Prev() bool
- func (iterator *TreeMapIterator[K, V]) PrevTo(f func(key K, value V) bool) bool
- func (iterator *TreeMapIterator[K, V]) Value() V
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TreeMap ¶
type TreeMap[K constraints.Ordered, V any] struct { // contains filtered or unexported fields }
func (*TreeMap[K, V]) All ¶
All passes each element of the container to the given function and returns true if the function returns true for all elements.
func (*TreeMap[K, V]) Any ¶
Any passes each element of the container to the given function and returns true if the function ever returns true for any element.
func (*TreeMap[K, V]) Ceiling ¶ added in v0.1.1
Ceiling finds the ceiling key-value pair for the input key. In case that no ceiling is found, then both returned values will be corresponding type's empty value.
Ceiling key is defined as the least key that is greater than or equal to the given key. A ceiling key may not be found, either because the map is empty, or because all keys in the map are less than the given key.
func (*TreeMap[K, V]) CeilingOrMax ¶ added in v0.1.1
Ceiling finds the ceiling key-value pair for the input key. If no ceiling is found, returns the key-value pair for the greatest key. In case that map is empty, then both returned values will be corresponding type's empty value.
Ceiling key is defined as the least key that is greater than or equal to the given key. A ceiling key may not be found, either because the map is empty, or because all keys in the map are less than the given key.
func (*TreeMap[K, V]) Clear ¶
func (m *TreeMap[K, V]) Clear()
Clear removes all elements from the map.
func (*TreeMap[K, V]) Each ¶
func (m *TreeMap[K, V]) Each(f func(key K, value V))
Each calls the given function once for each element, passing that element's key and value.
func (*TreeMap[K, V]) 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 (*TreeMap[K, V]) FindIter ¶ added in v0.1.1
func (m *TreeMap[K, V]) FindIter(key K) *TreeMapIterator[K, V]
FindIter returns an iterator pointing to the element with specified key. If no such element is found, a past-the-end iterator is returned. See: https://en.cppreference.com/w/cpp/container/map/find
func (*TreeMap[K, V]) Floor ¶ added in v0.1.1
Floor finds the floor key-value pair for the input key. In case that no floor is found, then both returned values will be corresponding type's empty value.
Floor key is defined as the greatest key that is less than or equal to the given key. A floor key may not be found, either because the map is empty, or because all keys in the map are greater than the given key.
func (*TreeMap[K, V]) FloorOrMin ¶ added in v0.3.0
FloorOrMin finds the floor key-value pair for the input key. If no floor is found, returns the key-value pair for the least key. In case that map is empty, then both returned values will be corresponding type's empty value.
Floor key is defined as the greatest key that is less than or equal to the given key. A floor key may not be found, either because the map is empty, or because all keys in the map are greater than the given key.
func (*TreeMap[K, V]) Get ¶
Get searches the element in the map by key and returns its value or empty value if key is not found in tree. Second return parameter is true if key was found, otherwise false.
func (*TreeMap[K, V]) Iterator ¶
func (m *TreeMap[K, V]) Iterator() *TreeMapIterator[K, V]
Iterator returns a stateful iterator whose elements are key/value pairs.
func (*TreeMap[K, V]) LowerBound ¶
func (m *TreeMap[K, V]) LowerBound(key K) *TreeMapIterator[K, V]
LowerBound returns an iterator pointing to the first element that is not less than key. If no such element is found, a past-the-end iterator is returned. See: https://en.cppreference.com/w/cpp/container/map/lower_bound
func (*TreeMap[K, V]) Map ¶
Map invokes the given function once for each element and returns a container containing the values returned by the given function as key/value pairs.
func (*TreeMap[K, V]) MarshalJSON ¶
MarshalJSON @implements json.Marshaler
func (*TreeMap[K, V]) Max ¶
Max returns the maximum key and its value from the tree map. If the map is empty, the third return parameter will be false.
func (*TreeMap[K, V]) Min ¶
Min returns the minimum key and its value from the tree map. If the map is empty, the third return parameter will be false.
func (*TreeMap[K, V]) Put ¶
func (m *TreeMap[K, V]) Put(key K, value V)
Put inserts key-value pair into the map.
func (*TreeMap[K, V]) Range ¶ added in v0.1.1
Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration.
func (*TreeMap[K, V]) Remove ¶
func (m *TreeMap[K, V]) Remove(key K)
Remove removes the element from the map by key.
func (*TreeMap[K, V]) ReverseRange ¶ added in v0.4.0
ReverseRange calls f sequentially in reverse order for each key and value present in the map. If f returns false, range stops the iteration.
func (*TreeMap[K, V]) Select ¶
Select returns a new container containing all elements for which the given function returns a true value.
func (*TreeMap[K, V]) UnmarshalJSON ¶
UnmarshalJSON @implements json.Unmarshaler
func (*TreeMap[K, V]) UpperBound ¶
func (m *TreeMap[K, V]) UpperBound(key K) *TreeMapIterator[K, V]
UpperBound returns an iterator pointing to the first element that is greater than key. If no such element is found, a past-the-end iterator is returned. See: https://en.cppreference.com/w/cpp/container/map/upper_bound
type TreeMapIterator ¶
type TreeMapIterator[K constraints.Ordered, V any] struct { // contains filtered or unexported fields }
func (*TreeMapIterator[K, V]) Begin ¶
func (iterator *TreeMapIterator[K, V]) Begin()
Begin resets the iterator to its initial state (one-before-first) Call Next() to fetch the first element if any.
func (*TreeMapIterator[K, V]) End ¶
func (iterator *TreeMapIterator[K, V]) End()
End moves the iterator past the last element (one-past-the-end). Call Prev() to fetch the last element if any.
func (*TreeMapIterator[K, V]) First ¶
func (iterator *TreeMapIterator[K, V]) First() bool
First moves the iterator to the first element and returns true if there was a first element in the container. If First() returns true, then first element's key and value can be retrieved by Key() and Value(). Modifies the state of the iterator
func (*TreeMapIterator[K, V]) IsBegin ¶
func (iterator *TreeMapIterator[K, V]) IsBegin() bool
IsBegin returns true if the iterator is in initial state (one-before-first)
func (*TreeMapIterator[K, V]) IsEnd ¶
func (iterator *TreeMapIterator[K, V]) IsEnd() bool
IsEnd returns true if the iterator is past the last element (one-past-the-end).
func (*TreeMapIterator[K, V]) Key ¶
func (iterator *TreeMapIterator[K, V]) Key() K
Key returns the current element's key. Does not modify the state of the iterator.
func (*TreeMapIterator[K, V]) Last ¶
func (iterator *TreeMapIterator[K, V]) Last() bool
Last moves the iterator to the last element and returns true if there was a last element in the container. If Last() returns true, then last element's key and value can be retrieved by Key() and Value(). Modifies the state of the iterator.
func (*TreeMapIterator[K, V]) Next ¶
func (iterator *TreeMapIterator[K, V]) Next() bool
Next moves the iterator to the next element and returns true if there was a next element in the container. If Next() returns true, then next element's key and value can be retrieved by Key() and Value(). If Next() was called for the first time, then it will point the iterator to the first element if it exists. Modifies the state of the iterator.
func (*TreeMapIterator[K, V]) NextTo ¶
func (iterator *TreeMapIterator[K, V]) NextTo(f func(key K, value V) bool) bool
NextTo moves the iterator to the next element from current position that satisfies the condition given by the passed function, and returns true if there was a next element in the container. If NextTo() returns true, then next element's key and value can be retrieved by Key() and Value(). Modifies the state of the iterator.
func (*TreeMapIterator[K, V]) Prev ¶
func (iterator *TreeMapIterator[K, V]) Prev() bool
Prev moves the iterator to the previous element and returns true if there was a previous element in the container. If Prev() returns true, then previous element's key and value can be retrieved by Key() and Value(). Modifies the state of the iterator.
func (*TreeMapIterator[K, V]) PrevTo ¶
func (iterator *TreeMapIterator[K, V]) PrevTo(f func(key K, value V) bool) bool
PrevTo moves the iterator to the previous element from current position that satisfies the condition given by the passed function, and returns true if there was a next element in the container. If PrevTo() returns true, then next element's key and value can be retrieved by Key() and Value(). Modifies the state of the iterator.
func (*TreeMapIterator[K, V]) Value ¶
func (iterator *TreeMapIterator[K, V]) Value() V
Value returns the current element's value. Does not modify the state of the iterator.