1 Star 0 Fork 127

烟圈/数据结构(C++模板实现)

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
test.cpp 24.19 KB
一键复制 编辑 原始数据 按行查看 历史
Y_Dash 提交于 2023-06-18 16:16 +08:00 . 队列补充doxygen
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882
/*!
* @file test.cpp
* @author CyberDash计算机考研, cyberdash@163.com(抖音id:cyberdash_yuan)
* @brief 队列测试.cpp文件
* @version 0.2.1
* @date 2021-10-9
*/
#include "test.h"
#include "linked_queue.h"
#include "circular_queue.h"
#include "double_ended_queue.h"
/*!
* @brief **测试-链式队列-长度**
* @note
* 测试-链式队列-长度
* ---------------
* ---------------
*
* ---------------
* + **1 声明队列**\n
* + **2 数据入队队列**\n
* + **3 打印队列长度**\n
*
*
* ---------------
*/
void Test_LinkedQueue_Length() {
cout << endl;
cout << "|------------------------ CyberDash ------------------------|" << endl;
cout << "| Test LinkedQueue Length |" << endl;
cout << "| 测试-链式队列-长度 |" << endl << endl << endl;
// ---------- 1 声明队列 ----------
LinkedQueue<string> old_memory_queue;
// ---------- 2 数据入队队列 ----------
string old_memory[12] = { "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月" };
for (int i = 0; i < 12; i++) {
cout << "old_memory_queue enqueue: " << old_memory[i] << endl;
old_memory_queue.EnQueue(old_memory[i]);
}
// ---------- 3 打印队列长度 ----------
cout << endl << "队列old_memory_queue的长度: " << old_memory_queue.Length() << endl;
cout << "-------------------------------------------------------------" << endl << endl;
}
/*!
* @brief **测试-链式队列-入队**
* @note
* 测试-链式队列-入队
* ---------------
* ---------------
*
* ---------------
* + **1 声明队列**\n
* + **2 数据入队队列**\n
* + **3 打印队列**\n
*
*
* ---------------
*/
void Test_LinkedQueue_EnQueue() {
cout << endl;
cout << "|------------------------ CyberDash ------------------------|" << endl;
cout << "| Test LinkedQueue Enqueue |" << endl;
cout << "| 测试-链式队列-入队 |" << endl << endl << endl;
// ---------- 1 声明队列 ----------
LinkedQueue<int> int_queue;
// ---------- 2 数据入队队列 ----------
cout << "Enqueue 4 integers." << endl << endl;
int_queue.EnQueue(1);
int_queue.EnQueue(2);
int_queue.EnQueue(3);
int_queue.EnQueue(4);
// ---------- 3 打印队列 ----------
cout << int_queue;
cout << "-------------------------------------------------------------" << endl << endl;
}
/*!
* @brief **测试-链式队列-出队**
* @note
* 测试-链式队列-出队
* ---------------
* ---------------
*
* ---------------
* + **1 声明队列**\n
* + **2 数据入队队列**\n
* + **3 队头出队**\n
* + **4 打印队列**\n
*
*
* ---------------
*/
void Test_LinkedQueue_DeQueue() {
cout << endl;
cout << "|------------------------ CyberDash ------------------------|" << endl;
cout << "| Test LinkedQueue Dequeue |" << endl;
cout << "| 测试-链式队列-出队 |" << endl << endl << endl;
// ---------- 1 声明队列 ----------
LinkedQueue<double> double_queue;
// ---------- 2 数据入队队列 ----------
cout << "double_queue入队4个数: 1.1, 2.2, 3.3, 4.4" << endl << endl;
double_queue.EnQueue(1.1);
double_queue.EnQueue(2.2);
double_queue.EnQueue(3.3);
double_queue.EnQueue(4.4);
cout << double_queue << endl;
// ---------- 3 队头出队 ----------
cout << "double_queue队头出队" << endl << endl;
double frontData;
double_queue.DeQueue(frontData);
// ---------- 4 打印队列 ----------
cout << double_queue;
cout << "-------------------------------------------------------------" << endl << endl;
}
/*!
* @brief **测试-链式队列-获取队头/队尾数据**
* @note
* 测试-链式队列-获取队头/队尾数据
* --------------------------
* --------------------------
*
* --------------------------
* + **1 声明队列**\n
* + **2 数据入队队列**\n
* + **3 打印队头/队尾数据**\n
*
*
* --------------------------
*/
void Test_LinkedQueue_GetFrontAndGetRear() {
cout << endl;
cout << "|------------------------ CyberDash ------------------------|" << endl;
cout << "| Test Queue Front & Rear |" << endl;
cout << "| 测试-链式队列-获取队头/获取队尾 |" << endl << endl << endl;
LinkedQueue<string> string_queue;
string_queue.EnQueue("听我的");
string_queue.EnQueue("买买买");
string_queue.EnQueue("买冰箱");
string_queue.EnQueue("什么都要听我的");
string_queue.EnQueue("闹够了没有");
string_queue.EnQueue("我不要你觉得");
string_queue.EnQueue("我要我觉得");
string front_data;
string rear_data;
string_queue.Front(front_data);
string_queue.Rear(rear_data);
cout << "The front of the queue: " << front_data << endl;
cout << "The rear of the queue: " << rear_data << endl;
cout << "-------------------------------------------------------------" << endl << endl;
}
/*!
* @brief **测试-链式队列-清空**
* @note
* 测试-链式队列-清空
* ---------------
* ---------------
*
* ---------------
* + **1 声明队列**\n
* + **2 数据入队队列**\n
* + **3 清空**\n
*
*
* ---------------
*/
void Test_LinkedQueue_IsEmpty() {
cout << endl;
cout << "|------------------------ CyberDash ------------------------|" << endl;
cout << "| Test LinkedQueue Clear |" << endl;
cout << "| 测试-链式队列-清空 |" << endl << endl << endl;
LinkedQueue<string> LinkinPark_song_queue;
LinkinPark_song_queue.EnQueue("<In the end>");
LinkinPark_song_queue.EnQueue("<Crawling>");
LinkinPark_song_queue.EnQueue("<One more light>");
bool is_empty = LinkinPark_song_queue.IsEmpty();
if (is_empty) {
cout << "LinkinPark_song_queue is empty." << endl;
} else {
cout << "LinkinPark_song_queue isn't empty." << endl;
}
cout << endl << "call function Clear." << endl << endl;
LinkinPark_song_queue.Clear();
is_empty = LinkinPark_song_queue.IsEmpty();
if (is_empty) {
cout << "LinkinPark_song_queue is empty." << endl;
} else {
cout << "LinkinPark_song_queue isn't empty." << endl;
}
cout << "-------------------------------------------------------------" << endl << endl;
}
/*!
* @brief **测试-链式队列-打印**
* @note
* 测试-链式队列-打印
* ---------------
* ---------------
*
* ---------------
* + **1 声明队列**\n
* + **2 数据入队队列**\n
* + **3 打印队列**\n
*
*
* ---------------
*/
void Test_LinkedQueue_Print() {
cout << endl;
cout << "|------------------------ CyberDash ------------------------|" << endl;
cout << "| Test LinkedQueue Operator<< |" << endl;
cout << "| 测试-链式队列-operator<< |" << endl << endl << endl;
LinkedQueue<string> string_queue;
string_queue.EnQueue("听我的");
string_queue.EnQueue("买买买");
string_queue.EnQueue("买冰箱");
string_queue.EnQueue("什么都要听我的");
string_queue.EnQueue("闹够了没有");
string_queue.EnQueue("我不要你觉得");
string_queue.EnQueue("我要我觉得");
cout << string_queue;
cout << "-------------------------------------------------------------" << endl << endl;
}
/*!
* @brief **测试-循环队列-长度**
* @note
* 测试-循环队列-长度
* ---------------
* ---------------
*
* ---------------
* + **1 声明队列**\n
* + **2 数据入队队列**\n
* + **3 打印队列长度**\n
*
*
* ---------------
*/
void Test_CircularQueue_Length() {
cout << endl;
cout << "|------------------------ CyberDash ------------------------|" << endl;
cout << "| Test CircularQueue Length |" << endl;
cout << "| 测试-循环队列-长度 |" << endl << endl << endl;
// ---------- 1 声明队列 ----------
CircularQueue<string> old_memory_queue;
// ---------- 2 数据入队队列 ----------
string old_memory[12] = { "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月" };
for (int i = 0; i < 12; i++) {
cout << "Old memory enqueue: " << old_memory[i] << endl;
old_memory_queue.EnQueue(old_memory[i]);
}
// ---------- 3 打印队列长度 ----------
cout << endl << "Old memory queue length: " << old_memory_queue.Length() << endl;
cout << "-------------------------------------------------------------" << endl << endl;
}
/*!
* @brief **测试-循环队列-入队**
* @note
* 测试-循环队列-入队
* ---------------
* ---------------
*
* ---------------
* + **1 声明队列**\n
* + **2 数据入队队列**\n
* + **3 打印队列**\n
*
* ---------------
*/
void Test_CircularQueue_EnQueue() {
cout << endl;
cout << "|------------------------ CyberDash ------------------------|" << endl;
cout << "| Test CircularQueue Enqueue |" << endl;
cout << "| 测试-循环队列-入队 |" << endl << endl << endl;
// 1 声明队列
CircularQueue<int> int_queue;
// 2 数据入队队列
cout << "Enqueue 4 integers." << endl << endl;
int_queue.EnQueue(1);
int_queue.EnQueue(2);
int_queue.EnQueue(3);
int_queue.EnQueue(4);
// 3 打印队列
cout << int_queue;
cout << "-------------------------------------------------------------" << endl << endl;
}
/*!
* @brief **测试-循环队列-出队**
* @note
* 测试-循环队列-出队
* ---------------
* ---------------
*
* ---------------
* + **1 声明队列**\n
* + **2 数据入队队列**\n
* + **3 队头出队**\n
* + **4 打印队列**\n
*
*
* ---------------
*/
void Test_CircularQueue_DeQueue() {
cout << endl;
cout << "|------------------------ CyberDash ------------------------|" << endl;
cout << "| Test CircularQueue Dequeue |" << endl;
cout << "| 测试-循环队列-出队 |" << endl << endl << endl;
// 1 声明队列
CircularQueue<double> double_queue;
// 2 数据入队队列
cout << "double_queue enqueue 4 numbers." << endl;
double_queue.EnQueue(1.1);
double_queue.EnQueue(2.2);
double_queue.EnQueue(3.3);
double_queue.EnQueue(4.4);
cout << double_queue << endl;
cout << "double_queue dequeue." << endl << endl;
// 3 队头出队
double frontData;
double_queue.DeQueue(frontData);
cout << double_queue;
double_queue.DeQueue(frontData);
double_queue.DeQueue(frontData);
double_queue.DeQueue(frontData);
// 4 打印队列
cout << double_queue;
cout << "-------------------------------------------------------------" << endl << endl;
}
/*!
* @brief **测试-循环队列-获取队头/队尾数据**
* @note
* 测试-循环队列-获取队头/队尾数据
* --------------------------
* --------------------------
*
* --------------------------
* + **1 声明队列**\n
* + **2 数据入队队列**\n
* + **3 打印队头/队尾数据**\n
*
*
* --------------------------
*/
void Test_CircularQueue_GetFrontAndGetRear() {
cout << endl;
cout << "|------------------------ CyberDash ------------------------|" << endl;
cout << "| Test CircularQueue Front & Rear |" << endl;
cout << "| 测试-循环队列-获取队头/获取队尾 |" << endl << endl << endl;
// 1 声明队列
CircularQueue<string> string_queue;
// 2 数据入队队列
string_queue.EnQueue("听我的");
string_queue.EnQueue("买买买");
string_queue.EnQueue("买冰箱");
string_queue.EnQueue("什么都要听我的");
string_queue.EnQueue("闹够了没有");
string_queue.EnQueue("我不要你觉得");
string_queue.EnQueue("我要我觉得");
// 3 打印队头/队尾数据
string front_data;
string rear_data;
string_queue.Front(front_data);
string_queue.Rear(rear_data);
cout << "The front of the queue: " << front_data << endl;
cout << "The rear of the queue: " << rear_data << endl;
cout << "-------------------------------------------------------------" << endl << endl;
}
/*!
* @brief **测试-循环队列-清空**
* @note
* 测试-循环队列-清空
* ---------------
* ---------------
*
* ---------------
* + **1 声明队列**\n
* + **2 数据入队队列**\n
* + **3 测试队列是否为空**\n
* + **4 清空**\n
* + **5 测试队列是否为空**\n
*
*
* ---------------
*/
void Test_CircularQueue_Clear() {
cout << endl;
cout << "|------------------------ CyberDash ------------------------|" << endl;
cout << "| Test CircularQueue Clear |" << endl;
cout << "| 测试-循环队列-清空 |" << endl << endl << endl;
// 1 声明队列
CircularQueue<string> LinkinPark_song_queue;
// 2 数据入队队列
LinkinPark_song_queue.EnQueue("<In the end>");
LinkinPark_song_queue.EnQueue("<Crawling>");
LinkinPark_song_queue.EnQueue("<One more light>");
// 3 测试队列是否为空
bool is_empty = LinkinPark_song_queue.IsEmpty();
if (is_empty) {
cout << "LinkinPark_song_queue is empty." << endl;
} else {
cout << "LinkinPark_song_queue isn't empty." << endl;
}
cout << endl << "call function Clear." << endl << endl;
// 4 清空
LinkinPark_song_queue.Clear();
// 5 测试队列是否为空
is_empty = LinkinPark_song_queue.IsEmpty();
if (is_empty) {
cout << "LinkinPark_song_queue is empty." << endl;
} else {
cout << "LinkinPark_song_queue isn't empty." << endl;
}
cout << "-------------------------------------------------------------" << endl << endl;
}
/*!
* @brief **测试-循环队列-打印**
* @note
* 测试-循环队列-打印
* ---------------
* ---------------
*
* ---------------
* + **1 声明队列**\n
* + **2 数据入队队列**\n
* + **3 打印队列**\n
*
*
* ---------------
*/
void Test_CircularQueue_Print() {
cout << endl;
cout << "|------------------------ CyberDash ------------------------|" << endl;
cout << "| Test CircularQueue Operator<< |" << endl;
cout << "| 测试-循环队列-operator<< |" << endl << endl << endl;
// 1 声明队列
LinkedQueue<string> string_queue;
// 2 数据入队队列
string_queue.EnQueue("听我的");
string_queue.EnQueue("买买买");
string_queue.EnQueue("买冰箱");
string_queue.EnQueue("什么都要听我的");
string_queue.EnQueue("闹够了没有");
string_queue.EnQueue("我不要你觉得");
string_queue.EnQueue("我要我觉得");
// 3 打印队列
cout << string_queue;
cout << "-------------------------------------------------------------" << endl << endl;
}
/*!
* @brief **测试-双端队列-长度**
* @note
* 测试-双端队列-长度
* ---------------
* ---------------
*
* ---------------
* + **1 声明队列**\n
* + **2 数据入队队列**\n
* + **3 打印队列长度**\n
*
*
* ---------------
*/
void Test_DoubleEndedQueue_Length() {
cout << endl;
cout << "|------------------------ CyberDash ------------------------|" << endl;
cout << "| Test DoubleEndedQueue Length |" << endl;
cout << "| 测试-双端队列-长度 |" << endl << endl << endl;
// ---------- 1 声明队列 ----------
DoubleEndedQueue<string> old_memory_queue;
// ---------- 2 数据入队队列 ----------
string old_memory[12] = { "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月" };
for (int i = 0; i < 12; i++) {
cout << "Old memory enqueue: " << old_memory[i] << endl;
old_memory_queue.PushBack(old_memory[i]);
}
// ---------- 3 打印队列长度 ----------
cout << endl << "Old memory queue length: " << old_memory_queue.Length() << endl;
cout << "-------------------------------------------------------------" << endl << endl;
}
/*!
* @brief **测试-双端队列-尾部入队**
* @note
* 测试-双端队列-尾部入队
* -------------------
* -------------------
*
* -------------------
* + **1 声明队列**\n
* + **2 数据入队队列**\n
* + **3 打印队列**\n
*
*
* -------------------
*/
void Test_DoubleEndedQueue_EnQueue() {
cout << endl;
cout << "|------------------------ CyberDash ------------------------|" << endl;
cout << "| Test DoubleEndedQueue PushBack |" << endl;
cout << "| 测试-双端队列-尾部入队 |" << endl << endl << endl;
// 1 声明队列
DoubleEndedQueue<int> int_queue;
// 2 数据入队队列
cout << "Enqueue 4 integers." << endl << endl;
int_queue.PushBack(1);
int_queue.PushBack(2);
int_queue.PushBack(3);
int_queue.PushBack(4);
// 3 打印队列
cout << int_queue;
cout << "-------------------------------------------------------------" << endl << endl;
}
/*!
* @brief **测试-循环队列-出队**
* @note
* 测试-循环队列-出队
* ---------------
* ---------------
*
* ---------------
* + **1 声明队列**\n
* + **2 数据入队队列**\n
* + **3 队头出队**\n
* + **4 打印队列**\n
*
*
* ---------------
*/
void Test_DoubleEndedQueue_DeQueue() {
cout << endl;
cout << "|------------------------ CyberDash ------------------------|" << endl;
cout << "| Test DoubleEndedQueue Dequeue |" << endl;
cout << "| 测试-双端队列-出队 |" << endl << endl << endl;
// 1 声明队列
CircularQueue<double> double_queue;
// 2 数据入队队列
cout << "double_queue enqueue 4 numbers." << endl;
double_queue.EnQueue(1.1);
double_queue.EnQueue(2.2);
double_queue.EnQueue(3.3);
double_queue.EnQueue(4.4);
cout << double_queue << endl;
cout << "double_queue dequeue." << endl << endl;
// 3 队头出队
double frontData;
double_queue.DeQueue(frontData);
cout << double_queue;
double_queue.DeQueue(frontData);
double_queue.DeQueue(frontData);
double_queue.DeQueue(frontData);
// 4 打印队列
cout << double_queue;
cout << "-------------------------------------------------------------" << endl << endl;
}
/*!
* @brief **测试-双端队列-获取队头/队尾数据**
* @note
* 测试-双端队列-获取队头/队尾数据
* --------------------------
* --------------------------
*
* --------------------------
* + **1 声明队列**\n
* + **2 数据入队队列**\n
* + **3 打印队头/队尾数据**\n
*
*
* --------------------------
*/
void Test_DoubleEndedQueue_GetFrontAndGetRear() {
cout << endl;
cout << "|------------------------ CyberDash ------------------------|" << endl;
cout << "| Test DoubleEndedQueue Front & Rear |" << endl;
cout << "| 测试-双端队列-获取队头/获取队尾 |" << endl << endl << endl;
// 1 声明队列
DoubleEndedQueue<string> string_queue;
// 2 数据入队队列
string_queue.PushBack("听我的");
string_queue.PushBack("买买买");
string_queue.PushBack("买冰箱");
string_queue.PushBack("什么都要听我的");
string_queue.PushBack("闹够了没有");
string_queue.PushBack("我不要你觉得");
string_queue.PushBack("我要我觉得");
// 3 打印队头/队尾数据
string front_data;
string rear_data;
string_queue.Front(front_data);
string_queue.Rear(rear_data);
cout << "The front of the queue: " << front_data << endl;
cout << "The rear of the queue: " << rear_data << endl;
cout << "-------------------------------------------------------------" << endl << endl;
}
/*!
* @brief **测试-双端队列-清空**
* @note
* 测试-双端队列-清空
* ---------------
* ---------------
*
* ---------------
* + **1 声明队列**\n
* + **2 数据入队队列**\n
* + **3 打印队列是否为空**\n
* + **4 清空**\n
* + **5 打印队列是否为空**\n
*
*
* ---------------
*/
void Test_DoubleEndedQueue_IsEmpty() {
cout << endl;
cout << "|------------------------ CyberDash ------------------------|" << endl;
cout << "| Test DoubleEndedQueue Clear |" << endl;
cout << "| 测试-双端队列-清空 |" << endl << endl << endl;
// 1 声明队列
DoubleEndedQueue<string> LinkinPark_song_queue;
// 2 数据入队队列
LinkinPark_song_queue.PushBack("<In the end>");
LinkinPark_song_queue.PushBack("<Crawling>");
LinkinPark_song_queue.PushBack("<One more light>");
// 3 打印队列是否为空
bool is_empty = LinkinPark_song_queue.IsEmpty();
if (is_empty) {
cout << "LinkinPark_song_queue is empty." << endl;
} else {
cout << "LinkinPark_song_queue isn't empty." << endl;
}
// 4 清空
cout << endl << "call function Clear." << endl << endl;
LinkinPark_song_queue.Clear();
// 5 打印队列是否为空
is_empty = LinkinPark_song_queue.IsEmpty();
if (is_empty) {
cout << "LinkinPark_song_queue is empty." << endl;
} else {
cout << "LinkinPark_song_queue isn't empty." << endl;
}
cout << "-------------------------------------------------------------" << endl << endl;
}
/*!
* @brief **测试-循环队列-打印**
* @note
* 测试-循环队列-打印
* ---------------
* ---------------
*
* ---------------
* + **1 声明队列**\n
* + **2 数据入队队列**\n
* + **3 打印队列**\n
*
*
* ---------------
*/
void Test_DoubleEndedQueue_Print() {
cout << endl;
cout << "|------------------------ CyberDash ------------------------|" << endl;
cout << "| Test DoubleEndedQueue Operator<< |" << endl;
cout << "| 测试-双端队列-operator<< |" << endl << endl << endl;
// 1 声明队列
DoubleEndedQueue<string> string_queue;
// 2 数据入队队列
string_queue.PushBack("听我的");
string_queue.PushBack("买买买");
string_queue.PushBack("买冰箱");
string_queue.PushBack("什么都要听我的");
string_queue.PushBack("闹够了没有");
string_queue.PushBack("我不要你觉得");
string_queue.PushBack("我要我觉得");
// 3 打印队列
cout << string_queue;
cout << "-------------------------------------------------------------" << endl << endl;
}
/*!
* @brief **测试-循环队列-队尾出队和队头入队**
* @note
* 测试-循环队列-队尾出队和队头入队
* ---------------------------
* ---------------------------
*
* ---------------------------
* + **1 声明队列**\n
* + **2 数据入队队列并打印**\n
* + **3 部分元素出队并打印**\n
*
*
* ---------------------------
*/
void Test_DoubleEndedQueue_PushAndPop() {
cout << endl;
cout << "|------------------------ CyberDash ------------------------|" << endl;
cout << "| Test DoubleEndedQueue Push & Pop |" << endl;
cout << "| 测试-双端队列-双向Push/双向Pop |" << endl << endl << endl;
// 1 声明队列
DoubleEndedQueue<int> int_queue;
// 2 数据入队队列并打印
int_queue.PushBack(4);
int_queue.PushBack(3);
int_queue.PushBack(2);
int_queue.PushBack(1);
int_queue.PushFront(4);
int_queue.PushFront(3);
int_queue.PushFront(2);
int_queue.PushFront(1);
cout << int_queue;
// 3 部分元素出队并打印
int_queue.PopFront();
int_queue.PopFront();
int_queue.PopBack();
int_queue.PopBack();
cout << endl;
cout << int_queue;
cout << "-------------------------------------------------------------" << endl << endl;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/iotcodes/data-structures-cpp.git
git@gitee.com:iotcodes/data-structures-cpp.git
iotcodes
data-structures-cpp
数据结构(C++模板实现)
master

搜索帮助