我正在使用 std :: deque 用于存储大量项目.我知道双端队列是作为向量列表实现的.这些向量的大小无法设置,但我徘徊了选择该大小的算法是什么.
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.
推荐答案deque被实现为向量的向量(向量列表将阻止恒定时间的随机访问).次要向量的大小取决于实现方式,一种常见的算法是使用恒定大小(以字节为单位).
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.