简体   繁体   English

C ++是否有标准队列?

[英]Does C++ have standard queue?

I know that there's a standard library vector in C++. 我知道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. 谢谢你们。

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!
}

std :: queue (容器适配器)

Yes, there's std::queue . 是的,有std::queue Implemented as "adaptors", on top of an existing container (since it's basically just a specialization). 在现有容器之上实现为“适配器”(因为它基本上只是一个专业化)。

Another good reference for the C++ standard libraries is http://www.cplusplus.com . C ++标准库的另一个很好的参考是http://www.cplusplus.com

Specifically their reference section: http://www.cplusplus.com/reference/ . 具体来说,他们的参考部分为: http : //www.cplusplus.com/reference/

Here's their page for std::queue: http://www.cplusplus.com/reference/stl/queue/ . 这是他们关于std :: queue的页面: http : //www.cplusplus.com/reference/stl/queue/

另外,您可能会发现std :: deque(双头队列)很有用,具体取决于您需要的队列

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM