队列使用方式
普通队列queue基本操作:
1.定义 qeque < 类型(如int)> q
2.队尾 q.back()
3.队首 q.front()
4.弹出队首 q.pop()
5.将x从队尾插入 q.push(x)
6.判断队列是否为空,空则返回1 q.empty()
7.返回元素个数 q.size()
双端队列deque基本操作:
1.定义 deque < 类型(如int)> e
2.队尾 e.back()
3.队首 e.front()
4.弹出队尾 e.pop_back()
5.弹出队首 e.pop_front()
6.将x从队尾插入 e.push_back(x);
7.将x从队首插入 e.push_front(x);
8.判断队列是否为空,空则返回1 e.empty()
9.返回元素个数 e.size()