stl堆栈和队列的内部实现(internal implementation of stl stack and queues)

编程入门 行业动态 更新时间:2024-10-28 07:25:24
stl堆栈和队列的内部实现(internal implementation of stl stack and queues)

我正在使用stl堆栈和队列来存储大量项目。 如何在内部实现标准模板库中的堆栈? 它是链表的形式吗? 或者是否有任何最大尺寸?

I am using a stl stacks and queues for storing a large collection of items. How is stack in standard template lib implemented internally? Is it in the form of linked list? or is there any maximum size given to it?

最满意答案

C ++标准库中的堆栈和队列都是容器适配器 。 这意味着他们使用指定的容器作为存储数据的基础手段。 默认情况下,它们都使用std::deque但你可以使用例如vector with

std::stack<int,std::vector<int>> s;

Both stacks and queues in C++ standard library are container adaptors. It means that they use specified container as the underlying means to store data. By default both of them use std::deque but you can use e.g. vector with

std::stack<int,std::vector<int>> s;

更多推荐

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

发布评论

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

>www.elefans.com

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