summaryrefslogtreecommitdiff
path: root/algo1w3/main.cpp
blob: 8f89afaba8e13e71bdfc2d26dfbf27907f0c26b9 (plain)
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
#include "IntDoubleLinkedList.h"

#include <cstdlib>
#include <ctime>
#include <chrono>
#include <iostream>

void testVraag1();
void testVraag2();

int main() {
	testVraag1();
	testVraag2();

	return 0;
}

void testVraag1() {
	const int SIZE = 20;
	IntDoubleLinkedList linkedList;
	std::chrono::steady_clock::time_point start, end; 

	std::srand(unsigned(time(nullptr)));

	for (int n = 0; n < SIZE; n++) {
		if ((n&1) == 0)
			linkedList.insertAtStart(std::rand());
		else
			linkedList.insertAtEnd(std::rand());
	}

	start = std::chrono::steady_clock::now();
	linkedList.rapidBubbleSort();// for (int n=0; n<(1<<25); n++);
	end = std::chrono::steady_clock::now();

	std::cout << "duration = " << std::chrono::duration_cast<std::chrono::microseconds>(end - start).count() << " us" << std::endl;

	linkedList.showAll();
}

void testVraag2() {
	IntDoubleLinkedList linkedList;

	for (int n = 0; n < 20; n++)
		linkedList.insertAction(n);

	for (int n = 0; n < 10; n++)
		std::cout << linkedList.undo() << std::endl;

	for (int n = 0; n < 5; n++)
		std::cout << linkedList.redo() << std::endl;

	linkedList.insertAction(100);

	std::cout << " ----- " << std::endl;
	linkedList.showAll();
}