Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does C++ have standard queue?

Tags:

c++

queue

I know that there's a standard library vector in C++. Is there a queue? An online search suggests there might be, but there's not much about it if there is one.

Edit: All right. Thanks a ton guys.

like image 807
Scott Avatar asked Oct 05 '09 10:10

Scott


4 Answers

Yes there is, you could choose the underlying container easily also if you are interested:

#include <queue>

int main()
{
    std::queue<int> myqueue;

    myqueue.push(3);
    int x = myqueue.front();
    myqueue.pop(); // pop is void!
}
like image 79
Khaled Alshaya Avatar answered Oct 08 '22 06:10

Khaled Alshaya


std::queue (container adaptor)

like image 21
aJ. Avatar answered Oct 08 '22 08:10

aJ.


Yes, there's std::queue. Implemented as "adaptors", on top of an existing container (since it's basically just a specialization).

like image 40
unwind Avatar answered Oct 08 '22 08:10

unwind


std::priority_queue and std::queue

like image 42
SebastianK Avatar answered Oct 08 '22 07:10

SebastianK