创建固定大小队列的向量(提升循环队列)
Creating a vector of fixed sized queue (boost circular queue)
我有两个问题:1. 如何创建提升循环队列向量?2. 我应该如何表示前者的矢量大小?
我尝试了以下方法,但出现错误
// Boost Circular Queue -- This works fine
boost::circular_buffer<pkt> pkt_queue(3);
// Vector of queues - This has errors, i also wish to initialize the vector
std::vector<pkt_queue> per_port_pkt_queue;
你想要一个队列向量:
#include <boost/circular_buffer.hpp>
struct pkt { int data; };
int main() {
// Boost Circular Queue -- This works fine
typedef boost::circular_buffer<pkt> pkt_queue;
pkt_queue a_queue(3);
// Vector of queues - This has errors, i also wish to initialize the vector
std::vector<pkt_queue> per_port_pkt_queue;
per_port_pkt_queue.emplace_back(3);
per_port_pkt_queue.emplace_back(3);
per_port_pkt_queue.emplace_back(3);
// or
per_port_pkt_queue.assign(20, pkt_queue(3)); // twenty 3-element queues
}
在科里鲁现场观看
相关文章:
- 显示循环双端队列的功能
- EnQueue 方法在循环队列中未正确返回C++?
- 实现循环阵列队列
- C++ 数据结构队列:使用 for 循环查找队列中最大的元素
- 优先级队列(使用 pairs<int,int> ) 根据 for 循环迭代器的顶级元素
- Qt的事件循环线程是安全的还是原子的?处理"队列连接"时如何同步?
- 使用循环队列和迭代器自动换行
- 为什么在使用队列处理扫雷中的相邻单元格时会出现无限循环?
- 在队列上的最后一个操作循环中的错误
- C++ 长度为 100 的循环队列类
- 标准::队列的基于范围的循环
- 循环队列和循环链表
- 查找循环队列中的元素数
- 复制构造函数不适用于循环队列
- 创建固定大小队列的向量(提升循环队列)
- 增加C++循环队列的容量
- 循环队列中的c++模板专用化
- 带有WH_KEYBOARD的SetWindowsHookEx卡在循环/队列中
- 循环队列中的pop()操作.我该如何移除物品呢?
- 在队列循环中找到最小值