A std::vector< std::pair< const key, std::vector< value > > >
allows you to have any ordering of the key
elements, whereas a std::multimap<key, value>
doesn't.
From cppreference:
Multimap is an associative container that contains a sorted list of key-value pairs, while permitting multiple entries with the same key. Sorting is done according to the comparison function Compare
, applied to the keys.
It sounds like you are asking what is the order among equivalent entries.
The order of the key-value pairs whose keys compare equivalent is the order of insertion and does not change. (since C++11)
You can keep a vector in the same order as what a multimap provides, by making sure that you insert new entries after all the existing equivalent entries, but before any entries who's keys are later in the order. A simple way would to gate all insertion through
vec.insert(std::upper_bound(vec.begin(), vec.end(), to_insert, key_compare), to_insert);