如何在C ++中创建队列? [英] how to create a queue in c++?

查看:134
本文介绍了如何在C ++中创建队列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实际上要编写的程序类型是:服务器中有不同的数据,我们必须将该数据发送到另一台服务器,并且在这些数据中,我们必须过滤数据,进行一些内部计算从我们这边开始,然后我们必须发送,因为我的想法是创建一个队列,数据可以在其中保留固定的时间..我们将进行内部计算并发送,到那时其他数据将驻留在另一个队列中但是关于如何在c ++中实现队列却无法弄清楚呢?

the kind of program that i actually want to write is:there are different data that comes in from a server and we have to send that data to another server,and among that data we have to filter data,make some internal calculation from our side and then we have to send,for that my idea is to create a queue ,where data can reside for a fixed time..we will do internal calculation and send and at that time other data that comes will reside in another queue but cant get idea ,about how to implement queue in c++?

推荐答案

您正在使用c ++的人,为什么不只使用c ++中的一种数据类型呢? STL?
您已经有了std :: queue,这似乎正是您所需要的.

如果您不能使用现有的队列,那么自己实施队列就不那么困难了.从概念上讲,它只是一个列表-您必须在列表中将新项目添加到末尾(尾部),并且必须从列表中删除起始(头)中的元素.

这是使用的std :: queue的示例: http://www.cplusplus.com/reference /stl/queue/pop/ [^ ]
Sine you''re using c++, why not just use one of the data-types from the STL?
You''ve got std::queue, which appears likely to be just what you need.

If you can''t use an existing one, it''s not that difficult to implement a queue yourself. Conceptually, it''s just a list - a list in which you must add new items to the end(tail) and with which you must remove elements from the start(head).

Here''s an example of std::queue in use: http://www.cplusplus.com/reference/stl/queue/pop/[^]




首先,您可以使用: http://en.wikipedia.org/wiki/Message_queue

这意味着必须将要发送到服务器的消息排队(以便在连接可用后就可以发送它们).
从Win32上的C ++使用它必须相对简单.

也许会对您有帮助:
在C ++/WIN32多线程应用程序中使用WIN32消息队列 [ ^ ]
http://www.zeromq.org/blog:multithreaded-server [ http://tim.klingt.org/boost_lockfree/ [ http://www.dinkum.nl/software/multithreading/doc/msgqueue.php [ ^ ]

问候,
亚历克斯
Hi,

Firstly you can use : http://en.wikipedia.org/wiki/Message_queue

This means that the messages to be sent to the server must be queued (so that they can be sent once the connection is available).
It must be relatively simple to use from C++ on Win32.

Maybe it will help you:
Using WIN32 Message Queue in C++ / WIN32 Multithreaded Applications[^]
http://www.zeromq.org/blog:multithreaded-server[^]
http://tim.klingt.org/boost_lockfree/[^]
http://www.dinkum.nl/software/multithreading/doc/msgqueue.php[^]

Regards,
Alex


使用 std :: deque [

这篇关于如何在C ++中创建队列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆