summaryrefslogtreecommitdiff
path: root/algo1w1/main.cpp
blob: 80451a2539b18812c0a868c10d8b6f24f73bb386 (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
#include "NAWOrderedArray.h"
#include "NAW.h"

#include "IntOrderedArray.h"

#include <iostream>
#include <sstream>

void testNAWOrderedArray();
void testIntOrderedArray();

int main() {
	testNAWOrderedArray();
	return 0;
}

void testNAWOrderedArray() {
	NAWOrderedArray array;

	for (int n = 0; n < 10; n++) {
		std::stringstream naam, adres, plaats;

		naam << "avans " << n + 1;
		adres << "onderwijsboulevard " << n + 1;
		plaats << "den bosch " << n + 1;

		array.add({ naam.str(), adres.str(), plaats.str() });
	}

	std::cout << array.find({"avans 7","onderwijsboulevard 7","den bosch 7"}) << std::endl;
	std::cout << array.find({"avans 7","onderwijsboulevard 8","den bosch 9"}) << std::endl;
	std::cout << array.add({"avans 7","onderwijsboulevard 8","den bosch 9"}) << std::endl;
//	std::cout << array.add({"avans 7","onderwijsboulevard 8","den bosch 9"}) << std::endl; // niet-gedefinieerd requirement...
	std::cout << array.remove({"avans 7","onderwijsboulevard 8","den bosch 9"}) << std::endl;
	std::cout << array.remove({"avans 7","onderwijsboulevard 8","den bosch 9"}) << std::endl;
	std::cout << array.replace({"avans 7","onderwijsboulevard 7","den bosch 7"}, {"avans 17","onderwijsboulevard 18","den bosch 19"}) << std::endl;
	std::cout << array.replace({"avans 1","onderwijsboulevard 2","den bosch 3"}, {"avans 17","onderwijsboulevard 18","den bosch 19"}) << std::endl;

	array.showAll();
}

void testIntOrderedArray() {
	IntOrderedArray array;

	for (int n = 1; n <= 10; n++) {
		if ((n&1) == 0)
			array.quickInsert(n+10);
		else
			array.quickInsert(n);
	}

	array.showAll();
}