-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathp1.cpp
More file actions
38 lines (32 loc) · 905 Bytes
/
Copy pathp1.cpp
File metadata and controls
38 lines (32 loc) · 905 Bytes
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
#include "ADTList.cpp"
#include<string>
using namespace std;
template<typename T>
void test(string name){
cout<<name<<":\n";
T list; string s="hit";
list.insertElem(0,"nuaa");
list.insertElem(0,"seu");
list.insertElem(1,"yau");
list.insertElem(0,"njust");
list.setElem(2,s);
cout<<"Origin list: "; list.traverse();
//for(auto x:list)
//cout<<x<<",";
//cout<<"\n";
cout<<"Length of list is "<<list.length()<<".\n";
list.getElem(1,s);
cout<<"2nd element is "<<s<<".\n";
list.priorElem("yau",s);
cout<<"Precursor of hit is "<<s<<".\n";
list.deleteElem(list.locateElem("seu"),s);
cout<<"After delete seu: "; list.traverse();
list.clear();
cout<<"After clear list: "; list.traverse();
}
int main(){
test<SquList<string>>("SquList");
cout<<endl;
test<LinkList<string>>("LinkList");
return 0;
}