3.30. 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, .empty? and .nonempty?: O(1)

Where N is the size of the map.

3.30.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.

3.30.2. TREE_MAP.of_each_pair(Pair_eacher)

Makes a tree ordered_map with the given pairs, with the natural ordering.

The Pair_eacher must support .each($consume). The each method must call $consume for each pair of a key and the corrensponding val.

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

3.30.3. kink/container/TREE_MAP.new([[$config = {}]])

Makes an empty ordered_map of the tree map implementation.

$config 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.