4.35. kink/container/TREE_MAP

Provides an ordered_map implementation which stores contents in a balanced binary tree.

This map implementation is a safe default choice, because it guarantees logarithmic worst-case computational complexity for .get, .set and so on.

Worst case computational orders of each operations are as follows:

* .get and .get_or: O(log N)

* .have_key?: O(log N)

* .pop_at: O(log N)

* .size and .empty?: O(1)

Where N is the size of the map.

4.35.1. TREE_MAP.of(K0 V0 K1 V1 ,,,)

Makes a tree ordered_map with the given keys and vals, with the natural ordering.

In the natural ordering, X precedes Y if and only if X < Y.

4.35.2. TREE_MAP.from_pairs(Pair_eacher)

`from_pairs` makes a tree ordered_map with the given pairs, with the natural ordering.

In the natural ordering, X precedes Y if and only if X < Y.

Precondition:

• `Pair_eacher` must be a sequence which support .each($consume) method. `each` method must call $consume for each pair of a key and the corresponding val.

4.35.3. kink/container/TREE_MAP.new(...[$config_fun = {}])

Makes an empty ordered_map of the tree map implementation.

$config_fun takes a Conf as an arg. Conf has the following method.

Conf.precede_fun($_precede?): sets $_precede? to be used to determine the strict weak ordering of keys. $_precede? must take two parameters, and returns true if the first parameter precedes the second one in the ordering, or false otherwise.

If Conf.precede_fun is not called, the map uses the natural ordering.