-
Notifications
You must be signed in to change notification settings - Fork 32
/
dll_test.cpp
39 lines (29 loc) · 942 Bytes
/
dll_test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "dll.h"
#include <iostream>
using std::string;
using std::to_string;
using std::cout;
using std::endl;
int main() {
DLList<int> int_list;
for (int i = 0; i < 10; i++)
int_list.add_to_head(i);
cout << int_list << endl;
// should print [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
DLList<string> str_list;
string str = "Hello ";
for (int i = 0; i < 4; i++)
str_list.add_to_tail(str + to_string(i));
cout << str_list << endl;
// should print [Hello 0, Hello 1, Hello 2, Hello 3]
DLList<string> str_list2 = str_list;
str_list.append(str_list2);
cout << str_list << endl;
// should print [Hello 0, Hello 1, Hello 2, Hello 3, Hello 0, Hello 1, Hello 2, Hello 3]
string key = "Hello 0";
while (str_list.contains(key))
str_list.remove(key);
cout << str_list << endl;
// should print [Hello 1, Hello 2, Hello 3, Hello 1, Hello 2, Hello 3]
return 0;
}