我的程序中有队列问题。有一个队列我想使用这个队列,只有另一个 id。这是我现在拥有的:
queue<R> queue;
queue<R> queue2;
...
while (! queue2.empty() )
{
R r = queue2.front();
queue2.pop();
queue.push(r);
}
但它是线性的。我希望可以在 O(1) 时间内完成。我尝试使用引用,但我失败了。
最佳答案
关于C++队列容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8874080/