Is it guaranteed that when a hash_map/unordered_map is loaded with the same items, they will have the same order when iterated? Basically I have a hashmap which I load from a file, and from which I periodically feed a limited number of items to a routine, after which I free the hashmap. After the items are consumed, I re-load the same file to the hashmap and want to get the next batch of items after the point where I stopped the previous time. The point at which I stop would be identified by the key.
Is it guaranteed that when a hash_map/unordered_map is loaded with the same items, they
Share
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
you can reasonably expect that name-value pairs in
map1andmap2go in the same order.