mardi 26 septembre 2023

How does resizing unordered_set impact performance?

As far as I'm aware, resizing an array (like push_back on a vector that requires resizing the array) is O(n) complexity. If this is the case, does this hold for insert in unordered_set? Does resizing the internal array make insert O(n)? Does resizing previous to inserting the elements decrease this time complexity because none of the data has to be copied? Finally, I believe that resizing does not require a rehash. Is this correct? If so, how?

Aucun commentaire:

Enregistrer un commentaire