STL内部:双端队列实施 [英] STL internals: deque implementation

查看:53
本文介绍了STL内部:双端队列实施的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 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.

这篇关于STL内部:双端队列实施的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆