合并两个 std::queue [英] Merge two std::queue

查看:52
本文介绍了合并两个 std::queue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

stl 中是否有任何函数可以连接两个 std::queue 对象?

Is there any function in stl that joins two std::queue objects?

推荐答案

std::queue 适配器不支持迭代,因此您实际上必须推出自己的方法来执行此操作.但鉴于您需要此功能,您可能应该考虑使用不同的容器.如果您需要随机访问,可能是 std::deque.如果您只需要像队列一样的前/后访问,请考虑 std::list,它可以在恒定时间内 spliced 在一起.

The std::queue adapter doesn't support iteration so you'd actually have to roll your own method to do this. But given that you need this functionality, you should probably consider a different container. If you need random access, the probably std::deque. If you only need front/back access like a queue consider std::list which can be spliced together in constant time.

这篇关于合并两个 std::queue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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