4.33. kink/container/ORDERED_MAP

4.33.1. type ordered_map

A subtype of `map` type which supports ordering of keys.

The ordering is defined by each ordered_set implementation.

See kink/container/MAP for `map` type.

`ordered_map` implementations:

• kink/container/TREE_MAP

• kink/container/FLAT_MAP

4.33.1.1. M.key_iter

`key_iter` returns an iter of the keys in the ordering of the map.

`key_iter` of `ordered_map` type suffices the constraints of the method with the same name of `map` type.

Example:

:TREE_MAP.require_from('kink/container/')

:Map <- TREE_MAP.of(
  'foo' 'FOO'
  'bar' 'BAR'
  'baz' 'BAZ'
  'qux' 'QUX'
  'grault' 'GRAULT'
)
Map.key_iter.each{(:K)
  stdout.print_line(K.repr)
}
# Output:
#   "bar"
#   "baz"
#   "foo"
#   "grault"
#   "qux"

4.33.1.2. M.pair_iter

`pair_iter` returns an iter of pairs of the pairs of [key val] in the ordering of the map.

`pair_iter` of `ordered_map` type suffices the constraints of the method with the same name of `map` type.

Example:

:TREE_MAP.require_from('kink/container/')

:Map <- TREE_MAP.of(
  'foo' 'FOO'
  'bar' 'BAR'
  'baz' 'BAZ'
  'qux' 'QUX'
  'grault' 'GRAULT'
)
Map.pair_iter.each{(:Pair)
  stdout.print_line(Pair.repr)
}
# Output:
#   ["bar" "BAR"]
#   ["baz" "BAZ"]
#   ["foo" "FOO"]
#   ["grault" "GRAULT"]
#   ["qux" "QUX"]

4.33.1.3. M.front_key

`front_key` returns the key which comes first in the ordering of the map.

Precondition:

• The map must not be empty.

Example:

:TREE_MAP.require_from('kink/container/')

:Map <- TREE_MAP.of(
  'foo' 'FOO'
  'bar' 'BAR'
  'baz' 'BAZ'
  'qux' 'QUX'
  'grault' 'GRAULT'
)
stdout.print_line(Map.front_key.repr) # => "bar"

4.33.1.4. M.back_key

`back_key` returns the key which comes last in the ordering of the map.

Precondition:

• The map must not be empty.

Example:

:TREE_MAP.require_from('kink/container/')

:Map <- TREE_MAP.of(
  'foo' 'FOO'
  'bar' 'BAR'
  'baz' 'BAZ'
  'qux' 'QUX'
  'grault' 'GRAULT'
)
stdout.print_line(Map.back_key.repr) # => "qux"

4.33.1.5. M.key_iter_from(Min_key)

`key_iter_from` returns an iter of the keys which are equivalent to or bigger than `Min_key` in the ordering of the map.

Precondition:

• Ordering between `Min_key` and the keys of the map must be able to be tested.

Example:

:TREE_MAP.require_from('kink/container/')

:Map <- TREE_MAP.of(
  'foo' 'FOO'
  'bar' 'BAR'
  'baz' 'BAZ'
  'qux' 'QUX'
  'grault' 'GRAULT'
)
Map.key_iter_from('f').each{(:K)
  stdout.print_line(K.repr)
}
# Output:
#   "foo"
#   "grault"
#   "qux"

4.33.1.6. M.pair_iter_from(Min_key)

`pair_iter_from` returns an iter of the pairs of [key val], keys of which are equivalent to or bigger than `Min_key` in the ordering of the map.

Precondition:

• Ordering between `Min_key` and the keys of the map must be able to be tested.

Example:

:TREE_MAP.require_from('kink/container/')

:Map <- TREE_MAP.of(
  'foo' 'FOO'
  'bar' 'BAR'
  'baz' 'BAZ'
  'qux' 'QUX'
  'grault' 'GRAULT'
)
Map.pair_iter_from('f').each{(:Pair)
  stdout.print_line(Pair.repr)
}
# Output:
#   ["foo" "FOO"]
#   ["grault" "GRAULT"]
#   ["qux" "QUX"]

4.33.2. ORDERED_MAP.is?(Val)

`is?` returns whether `Val` is an ordered_map.