2024-02-21 09:31:34 +08:00
|
|
|
|
/**
|
|
|
|
|
* File: queue.cpp
|
|
|
|
|
* Created Time: 2022-11-28
|
|
|
|
|
* Author: qualifier1024 (2539244001@qq.com)
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "../utils/common.hpp"
|
|
|
|
|
|
|
|
|
|
/* Driver Code */
|
|
|
|
|
int main() {
|
2024-02-23 14:47:33 +08:00
|
|
|
|
/* <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
2024-02-21 09:31:34 +08:00
|
|
|
|
queue<int> queue;
|
|
|
|
|
|
2024-02-23 14:47:33 +08:00
|
|
|
|
/* Ԫ<><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
2024-02-21 09:31:34 +08:00
|
|
|
|
queue.push(1);
|
|
|
|
|
queue.push(3);
|
|
|
|
|
queue.push(2);
|
|
|
|
|
queue.push(5);
|
|
|
|
|
queue.push(4);
|
2024-02-23 14:47:33 +08:00
|
|
|
|
cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD> queue = ";
|
2024-02-21 09:31:34 +08:00
|
|
|
|
printQueue(queue);
|
|
|
|
|
|
2024-02-23 14:47:33 +08:00
|
|
|
|
/* <20><><EFBFBD>ʶ<EFBFBD><CAB6><EFBFBD>Ԫ<EFBFBD><D4AA> */
|
2024-02-21 09:31:34 +08:00
|
|
|
|
int front = queue.front();
|
2024-02-23 14:47:33 +08:00
|
|
|
|
cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD> front = " << front << endl;
|
2024-02-21 09:31:34 +08:00
|
|
|
|
|
2024-02-23 14:47:33 +08:00
|
|
|
|
/* Ԫ<>س<EFBFBD><D8B3><EFBFBD> */
|
2024-02-21 09:31:34 +08:00
|
|
|
|
queue.pop();
|
2024-02-23 14:47:33 +08:00
|
|
|
|
cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD> front = " << front << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӻ<EFBFBD> queue = ";
|
2024-02-21 09:31:34 +08:00
|
|
|
|
printQueue(queue);
|
|
|
|
|
|
2024-02-23 14:47:33 +08:00
|
|
|
|
/* <20><>ȡ<EFBFBD><C8A1><EFBFBD>еij<D0B5><C4B3><EFBFBD> */
|
2024-02-21 09:31:34 +08:00
|
|
|
|
int size = queue.size();
|
2024-02-23 14:47:33 +08:00
|
|
|
|
cout << "<EFBFBD><EFBFBD><EFBFBD>г<EFBFBD><EFBFBD><EFBFBD> size = " << size << endl;
|
2024-02-21 09:31:34 +08:00
|
|
|
|
|
2024-02-23 14:47:33 +08:00
|
|
|
|
/* <20>ж϶<D0B6><CFB6><EFBFBD><EFBFBD>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA> */
|
2024-02-21 09:31:34 +08:00
|
|
|
|
bool empty = queue.empty();
|
2024-02-23 14:47:33 +08:00
|
|
|
|
cout << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>Ϊ<EFBFBD><EFBFBD> = " << empty << endl;
|
2024-02-21 09:31:34 +08:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|