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;更多推荐
发布评论