I want to use unordered_map
.
If there's a collision, two elements get inside the same bucket.
I want to order these two elements, so, ifstd::unordered_map<int, int> unorderedMap;
unorderedMap[1] = 1; unorderedMap[12] = 12;
orunorderedMap[12] = 12; unorderedMap[1] = 1;
When I iterate the bucket, I want to get the same order inside of it. For example:
for(int i = 0; i < unorderedMap.bucket_count(); i++)
{
fprintf(stderr, "bucket [%d]\n", i);
for(std::unordered_map<int, int>::local_iterator it = unorderedMap.begin(i); it != unorderedMap.end(i); ++it)
{
fprintf(stderr, "k[%d], v[%d]\n", it->first, it->second);
}
fprintf(stderr, "\n");
}
I'll get:
output:
bucket [0]
bucket [1]
k[1], v[1]
k[12], v[12]
bucket [2]
...
Every time
Aucun commentaire:
Enregistrer un commentaire