6.28. kink/container/FLAT_MAP

Provides an `order_map` implementation which stores keys in a sorted vector.

Flat map is a good choice when keys are rarely inserted or deleted, or the size of the map is small.

6.28.1. FLAT_MAP.new(...[$config={}])

`new` returns a new empty flat `order_map`.

Config method

C.order($up_to?): default = {(:X :Y) X <= Y }

Total order relation of keys

$up_to? must be a function which takes two args X and Y. `up_to?(X Y)` must return the bool value of `X up-to Y`, where `up-to` is the total order relation of keys.

Preconditions

$up_to? must be a function which takes two values and returns a `bool`.

Example: default order

Example: custom order

6.28.2. FLAT_MAP.of(...[K0 V0 K1 V1 ,,,])

`of` makes a new flat `order_map` which contains the given keys and values. Keys are ordered by `<=` operator, or `op_le` method.

The result map has key-value pairs (K0, V0), (K1, V1), (K2, V2) ,,,.

Precondition

`K0`, `K1`, `K2` ,,, must be in the domain of keys.

Example