📄 main.cpp
字号:
#include <iostream>#include "datastructs.h"using namespace std;int main(){ // Q is a singly-linked list Queue<double> Q; // Add numbers to the end Q.EnQueue( 3.0 ); Q.EnQueue( 4.0 ); // Iterate from front to back Queue<double>::Iterator i; for ( i = Q.Begin(); i != Q.End(); i++ ) cout << *i << endl; // Remove both numbers Q.DeQueue(); Q.DeQueue(); // Confirm that iteration over an empty list works for ( i = Q.Begin(); i != Q.End(); i++ ) cout << *i << endl; cout << endl; // D is a doubly-linked list DQueue<int> D; // Add the numbers 0 through 9, in that order for ( int j = 0; j < 10; j++ ) D.PushBack( j ); // Then, iterate through the list from back to front DQueue<int>::ReverseIterator r; for ( r = D.RBegin(); r != D.REnd(); r++ ) cout << *r << endl; cout << endl; // Remove the first and last numbers D.PopFront(); D.PopBack(); // Iterate again to confirm they're removed for ( r = D.RBegin(); r != D.REnd(); r++ ) cout << *r << endl;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -