The Teej Posted June 19, 2009 Share Posted June 19, 2009 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 More sharing options...
0 code.kliu.org Posted June 19, 2009 Share Posted June 19, 2009 (edited) 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 June 19, 2009 by kliu0x52 Link to comment Share on other sites More sharing options...
0 The Teej Posted June 22, 2009 Author Share Posted June 22, 2009 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 More sharing options...
Question
The Teej
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