问题
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.
回答1:
std::queue (container adaptor)
回答2:
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!
}
回答3:
Yes, there's std::queue. Implemented as "adaptors", on top of an existing container (since it's basically just a specialization).
回答4:
std::priority_queue and std::queue
回答5:
http://www.sgi.com/tech/stl/queue.html
回答6:
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/.
回答7:
Also, you might find std::deque (double ended queue) useful, depending on what you need a queue for
来源:https://stackoverflow.com/questions/1519215/does-c-have-standard-queue