Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

STL internals: deque implementation

Tags:

c++

stl

internals

I am using a std::deque for storing a large collection of items.
I know that deques is implemented as a list of vectors. The size of those vectors cannot be set but I wander what is the algorithm for choosing that size.

like image 1000
cprogrammer Avatar asked Apr 20 '11 09:04

cprogrammer


1 Answers

deque is implemented as a vector of vectors (a list of vectors would impede the constant time random access). The size of the secondary vectors is implementation dependent, a common algorithm is to use a constant size in bytes.

like image 73
AProgrammer Avatar answered Oct 03 '22 22:10

AProgrammer