MPS 2022.2 Help

Sorted Map

A subtype of map that provides iteration over keys conforming to the natural sorting order, backed by a tree map.

Sorted map type

map<KeyType, ValueType>

Subtypes

Supertypes

Comparable types

none

map<KeyType, ValueType>

java.util.SortedMap<KeyType, ValueType>

Sorted map creation

new treemap

Parameter type

Result type

(KeyType => ValueType)...

map<KeyType, ValueType>

Creates an empty tree map. Optionally, initial values may be specified right in the new map creation expression.

sorted_map<string, int> map = new treemap<string, int> {"A" => 1, "B" => 2, "C" => 3};

Operations on sorted map

headMap

Operand type

Parameter type

Result type

sorted_map<KeyType, ValueType>

KeyType

sorted_map<KeyType, ValueType>

Results in a sorted_map that is a submap of the original map, containing all the mappings in the original sorting order, starting with the first key and up to but not including the specified key.

map.headMap (upTo);

tailMap

Operand type

Parameter type

Result type

sorted_map<KeyType, ValueType>

KeyType

sorted_map<KeyType, ValueType>

Results in a sorted_map that is a submap of the original map, containing all the mappings in the original sorting order, starting with the specified key.

map.tailMap (from);

subMap

Operand type

Parameter type

Result type

sorted_map<KeyType, ValueType>

KeyType, KeyType

sorted_map<KeyType, ValueType>

Results in a sorted_map that is a submap of the original map, containing all the mappings in the original sorting order, starting with the first specified key and up to but not including the second specified key.

map.tailMap (from,upTo);

Last modified: 14 September 2021