3.31. kink/container/TREE_SET

Provides an ordered_set implementation which stores all the elements in a balanced binary tree.

This implementation can be a safe default choice, because it guarantees logarithmic worst-case computational complexity for .push and .remove methods.

Worst-case computational orders of each operations are as follows:

* have?: O(log N)

* push: O(log N)

* remove: O(log N)

* size, empty?, nonempty?: O(1)

Where N is the size of the set.

3.31.1. TREE_SET.of(... Elems)

Makes a tree set with the natural ordering, containing Elems.

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

3.31.2. TREE_SET.of_each(Eacher)

Makes a tree set with the natural ordering, containing each element of the Eacher.

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

3.31.3. TREE_SET.new([[$config = {}]])

Makes an empty ordered_set with the tree set implementation.

$config must take a Conf as a param. The Conf val has the following method.

Conf.precede_fun($_precede?): sets $_precede? to be used to determine the strict weak ordering of elems. $_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 natural ordering is used.