STL内部:双端队列实施

编程入门 行业动态 更新时间:2024-10-07 20:30:48
本文介绍了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内部:双端队列实施

本文发布于:2023-11-30 06:44:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1649060.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:队列   STL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!