-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathListTest.cpp
More file actions
57 lines (47 loc) · 1.43 KB
/
Copy pathListTest.cpp
File metadata and controls
57 lines (47 loc) · 1.43 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//
// Created by 赵健 on 2021/8/17.
//
#include "ListTest.h"
#include "../../utils/Utils.h"
#include <iostream>
#include <list>
#include <iterator>
//#include <algorithm>
void ListTest::test() {
using namespace std;
list<int> one(5, 2); // ListTest of 5 2s
int stuff[5] = {1,2,4,8,6};
list<int> two;
two.insert(two.begin(), stuff, stuff+5);
int more[6] = {6,4,2,4,6,5};
list<int> three(two);
three.insert(three.end(), more, more+6);
cout << "List one:";
for_each(one.begin(), one.end(), Utils::outint);
cout << endl << "List two:";
for_each(two.begin(), two.end(), Utils::outint);
cout << endl << "List Three:";
for_each(three.begin(), three.end(), Utils::outint);
three.remove(2);
cout << endl << "List three minus 2s:";
for_each(three.begin(), three.end(), Utils::outint);
three.splice(three.begin(), one);
cout << endl << "List three after splice:";
Utils::printList(three);
Utils::println("List one:");
Utils::printList(one);
three.unique();
Utils::println("List three after unique: ");
Utils::printList(three);
three.sort();
three.unique();
Utils::println("List three after sort & unique :");
Utils::printList(three);
two.sort();
Utils::println("Sorted two :");
Utils::printList(two);
three.merge(two);
Utils::println("Sorted two merged into three:");
Utils::printList(three);
Utils::println("");
}