Hi friends.
I want to ask if somebody can help me in this situation :
I do following code :
<code>
unordered_multimap<SetPartition,int> sparts;
//fill this sparts with elements
for(auto asp : sparts) {
const SetPartition& sp = asp.first;
//if (used.find(sp)!=used.end()) continue;
//used.insert(sp);
int bucketI = sparts.bucket(sp);
int bucketSize = sparts.bucket_size(bucketI);
auto range = sparts.equal_range(sp);
for(auto v = range.first; v!=range.second;++v) {
//...
}
//...
}
</code>
For my sorprise it never enter this second loop. I think it must have at least one element, if not why why we have asp ? Also, bucketSize=0. I believed it need to be =1.
Somebody can explain me why i not found nothing with a key, or explain me what is wrong ?
You declare your variable sparts as an empty unordered_multimap. It will not have any elements upfront (thus the size will be zero). Your first for loop is a range-based for loop. Since there's nothing in the map, it won't even execute.
If your loop does execute, there's probably something you aren't showing us in your code (probably the initialization of the map).
Thanks for your answer.
I put in comments :
//fill this sparts with elements
This mean i use "insert" many times there, its only i not show it explicitily.
I also say, it enter the first loop, but not enter the second loop.
So , in this case, you know why not ?
Between first "for" and second "for" i not erase any element.
Daniel
and Subset have a member variable hash a integer which is calculated in construction time :
size_t hash;
In time in which i insert a {SetPartition,int} into this Hash, its ok, but later it is invalidatet because i forget to put hash member in copy function and copy constructor.
Now, this is in order.
Thanks for you try.
Daniel