#include <iostream>
#include <cstdlib>
#include <chrono>
#include <random>
#include <ctime>
	
#include "row.hpp"
#include "row.cpp" 
#include "sorting_algorithms.hpp" 

using namespace std;
using namespace std::chrono;

int main() {
	srand(time(0));

	uint32_t sizes[]={1000,10000};

	uint32_t n = 10;
	int *b = new int[n];

	for (uint32_t i = 0; i < n; i++) {
		b[i] = rand() % 100;
	}

	Row<int> *a = new Row<int>(b, n); 
    
	bubble_sort(*a);
    
	cout << "Bubble sort test: " << *a << endl;

	delete a;
	delete[] b;



	for (uint32_t n : sizes) {
		cout << "\n--- Δοκιμή για n = " << n << " ---" << endl;

		double* temp= new double[n];
 		Row<double> initial_row(temp, n);

 	
	
		for (uint32_t i = 0; i < n; i++) {
		temp[i] = (double)rand() / RAND_MAX * 20000.0 - 10000.0;
   		}


		//Quick sort
		Row<double> r(temp, n);
		auto start = high_resolution_clock::now();
		quick_sort(r);
		auto end = high_resolution_clock::now();

		duration<double> diff = end - start;
	   	cout << "Quick Sort time: " << diff.count() << " s" << endl; 

	   	//Merge sort
 	  	Row<double> r_merge = initial_row;
	   	auto s2 = high_resolution_clock::now();
 	  	merge_sort(r_merge);
	   	auto e2 = high_resolution_clock::now();
	   	cout << "Merge Sort:     " << duration<double>(e2 - s2).count() << " s" << endl;

 	  	//Insertion Sort
 	  	Row<double> r_ins = initial_row;
 	  	auto s3 = high_resolution_clock::now();
 	  	insertion_sort(r_ins);
	   	auto e3 = high_resolution_clock::now();
 	  	cout << "Insertion Sort: " << duration<double>(e3 - s3).count() << " s" << endl;

 	  	//Selection Sort 
 	  	Row<double> r_sel = initial_row;
 	  	auto s4 = high_resolution_clock::now();
	   	selection_sort(r_sel);
	   	auto e4 = high_resolution_clock::now();
 	  	cout << "Selection Sort: " << duration<double>(e4 - s4).count() << " s" << endl;

 	  	//Bubble Sort
	   	Row<double> r_bub = initial_row;
	   	auto s5 = high_resolution_clock::now();
	   	bubble_sort(r_bub);
 	  	auto e5 = high_resolution_clock::now();
	   	cout << "Bubble Sort:    " << duration<double>(e5 - s5).count() << " s" << endl;

	   	//Rank Sort (Enumeration)
 	  	Row<double> r_rank = initial_row;
 	  	auto s6 = high_resolution_clock::now();
	   	enumeration_sort(r_rank);
	   	auto e6 = high_resolution_clock::now();
	   	cout << "Rank Sort:      " << duration<double>(e6 - s6).count() << " s" << endl;

	   	delete[] temp;
 }





    return 0;
} 
