• 0

[C++] STL Vector resizing


Question

Just a quick question,

Is STL Vector resizing free, an inexpensive function or an expensive function (talking in terms of processing power)?

Thanks.

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

The cost of random access is always expensive shifting and resizing (though the amortized resizing cost can be reduced if you sacrifice memory by resizing geometrically). So yes, STL vector resizing is expensive: O(n) per operation.

Edited by kliu0x52
Link to comment
Share on other sites

  • 0
The cost of random access is always expensive shifting and resizing (though the amortized resizing cost can be reduced if you sacrifice memory by resizing geometrically). So yes, STL vector resizing is expensive: O(n) per operation.

Ah, ok :/ Thanks!

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.