2022-11-24 18:04:38 +00:00
|
|
|
/*
|
|
|
|
* File: queue.cpp
|
2022-11-28 13:07:55 +00:00
|
|
|
* Created Time: 2022-11-28
|
|
|
|
* Author: qualifier1024 (2539244001@qq.com)
|
2022-11-24 18:04:38 +00:00
|
|
|
*/
|
|
|
|
|
2022-11-26 20:19:16 +00:00
|
|
|
#include "../include/include.hpp"
|
|
|
|
|
2022-11-28 18:21:49 +00:00
|
|
|
|
|
|
|
/* Driver Code */
|
2022-11-28 13:07:55 +00:00
|
|
|
int main(){
|
|
|
|
/* 初始化队列 */
|
|
|
|
queue<int> queue;
|
|
|
|
|
|
|
|
/* 元素入队 */
|
|
|
|
queue.push(1);
|
|
|
|
queue.push(3);
|
|
|
|
queue.push(2);
|
|
|
|
queue.push(5);
|
|
|
|
queue.push(4);
|
|
|
|
cout << "队列 queue = ";
|
|
|
|
PrintUtil::printQueue(queue);
|
|
|
|
|
|
|
|
/* 访问队首元素 */
|
|
|
|
int front = queue.front();
|
|
|
|
cout << "队首元素 front = " << front << endl;
|
|
|
|
|
|
|
|
/* 元素出队 */
|
|
|
|
queue.pop();
|
|
|
|
cout << "出队元素 front = " << front << ",出队后 queue = ";
|
|
|
|
PrintUtil::printQueue(queue);
|
|
|
|
|
|
|
|
/* 获取队列的长度 */
|
|
|
|
int size = queue.size();
|
|
|
|
cout << "队列长度 size = " << size << endl;
|
|
|
|
|
|
|
|
/* 判断队列是否为空 */
|
2022-11-29 18:27:26 +00:00
|
|
|
bool empty = queue.empty();
|
|
|
|
cout << "队列是否为空 = " << empty << endl;
|
2022-11-28 13:07:55 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|