Technically no, they are not guaranteed to be in any particular order.
In practice however, given that you use deterministic hash function, what you want to do should be fine.
consider
std::string name;
std::string value;
std::unordered_map <std::string, std::string> map1;
std::unordered_map <std::string, std::string> map2;
while (read_pair (name, value))
{
map1[name] = value;
map2[name] = value;
}
you can reasonably expect that name-value pairs in map1
and map2
go in the same order.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…