Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

internal implementation of stl stack and queues

Tags:

c++

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?

like image 328
user3250183 Avatar asked Aug 15 '14 15:08

user3250183


1 Answers

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;
like image 122
Wojtek Surowka Avatar answered Oct 13 '22 06:10

Wojtek Surowka