tags:

views:

276

answers:

7

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.

+4  A: 

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

unwind
+8  A: 

std::queue (container adaptor, From sgi site )

aJ
+1 for the simplest answer. I always feel people should google first before asking.
Ashwin
Ashwin, I did google. I didn't find this site though. I'm bookmarking this one.
Scott
@Scott, You can also refer very good book by Jossutis ( Addison Wesley - C++ Standard Library, The A Tutorial and Reference)
aJ
aJ: That's probably my best bet. When I took programming, the university had switched to teaching C# as standard, so I didn't pick up on much C++. Now I want to rewrite this program of mine in C++, but it's going slowly. A book would be a great reference. I'll look into your suggestion. Thanks!
Scott
@Ashwin: The goal of SO is to be the *result* when people google. Saying people should try to find the answer elsewhere isn't helpful for the person asking the question *or* for SO.
jalf
+2  A: 

http://www.sgi.com/tech/stl/queue.html

Lieven
+3  A: 

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!
}
AraK
+3  A: 

std::priority_queue and std::queue

SebastianK
A: 

Also, you might find std::deque (double ended queue) useful, depending on what you need a queue for

pxb
A: 

Another good reference for the C++ standard libraries is http://www.cplusplus.com.

Specifically their reference section: http://www.cplusplus.com/reference/.

Here's their page for std::queue: http://www.cplusplus.com/reference/stl/queue/.

Daniel Bingham