vendredi 27 mai 2016

unordered_map rehasing on erase()

I am not entirely clear on whether unordered_map is allowed to perform a rehash when doing an erase()

It is pretty clear that rehashing can happen during insert() thus invalidating all iterators and references:

http://ift.tt/25mF6fi

But erase() seems to preserve all iterators and references except for the ones erased:

http://ift.tt/1u1kIxc

However, that last page and the Standard, indicate that erase() worst execution time is O(size). What operation can take linear time to complete and not modify the container in a way it invalidates iterators?

This post suggests that iterators are invalidated during erasure: http://ift.tt/25mFV7G

I also read somewhere that a future proposal will allow rehashing on erase(). Is that true?

If indeed rehashing occurs, the old iterate and erase algorithm is wrong right?

Aucun commentaire:

Enregistrer un commentaire