December 2001
Intermediate to advanced
304 pages
6h 25m
English
vector and dequeDifficulty: 3
What is the difference between vector and deque? When should you use each one? And how can you properly shrink such containers when you no longer need their full capacity? These answers and more, as we consider news updates from the standards front.
In the standard library, vector and deque provide similar services. Which should you typically use? Why? Under what circumstances would you use the other?
What does the following code do?
vector<C> c( 10000 ); c.erase( c.begin()+10, c.end() ); c.reserve( 10 );
A vector or deque typically reserves extra internal storage as a hedge against future growth, to prevent too-frequent reallocation as new elements are added. Is it possible to completely clear a
Read now
Unlock full access