Documentation ¶
Index ¶
- type Tree
- func (tree Tree[K, V]) Equal(other Tree[K, V], f cmpFunc[V]) bool
- func (tree Tree[K, V]) ForEach(f eachFunc[K, V])
- func (tree Tree[K, V]) Insert(key K, value V) Tree[K, V]
- func (tree Tree[K, V]) InsertOrMerge(key K, value V, f mergeFunc[V]) Tree[K, V]
- func (tree Tree[K, V]) Lookup(key K) (V, bool)
- func (tree Tree[K, V]) Merge(other Tree[K, V], f mergeFunc[V]) Tree[K, V]
- func (tree Tree[K, V]) Remove(key K) Tree[K, V]
- func (tree Tree[K, V]) Size() (res int)
- func (tree Tree[K, V]) String() string
- func (tree Tree[K, V]) StringFiltered(pred func(k K, v V) bool) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Tree ¶
type Tree[K, V any] struct { // contains filtered or unexported fields }
func (Tree[K, V]) Equal ¶
Returns whether two maps are equal. Values are compared with the provided function. This operation also skips processing of shared subtrees.
func (Tree[K, V]) ForEach ¶
func (tree Tree[K, V]) ForEach(f eachFunc[K, V])
Call the given function once for each key-value pair in the map.
func (Tree[K, V]) Insert ¶
Inserts the given key-value pair into the map. Replaces previous value with the same key if it exists.
func (Tree[K, V]) InsertOrMerge ¶
Inserts the given key-value pair into the map. If a previous mapping (prevValue) exists for the key, the inserted value will be `f(value, prevValue)`.
func (Tree[K, V]) Merge ¶
Merges two maps. If both maps contain a value for a key, the resulting map will map the key to the result of `f` on the two values. `f` must be commutative and idempotent! This operation is made fast by skipping processing of shared subtrees. Merging a tree with itself after r updates should have complexity equivalent to `O(r * (keysize + f))`.
func (Tree[K, V]) Size ¶
Returns the number of key-value pairs in the map. NOTE: Runs in linear time in the size of the map.