


#include <iostream>
#include <string>
#include <vector>
#include "stdlib.h"
#include "qglobal.h"
#include <qthread.h>

using namespace std;

class Slave;

class Master{
	private:
		vector<Slave*> slaves;
	public:
		void response(string);
		void sortArray(vector<int> v);
		
};
class Slave{
	protected:
		Master *m; //required for the response
	public:
		Slave(Master *master){m=master;}
		vector<int> v;
		virtual void doSort()=0;
};

class Quicksort: public Slave{ //1. implementation of Slave
	public:
	Quicksort(vector<int> vec, Master *master):Slave(master){v=vec;}
	void doSort();
	void quicksort(int start, int ende);
	int split(int, int);
};
class BubbleSort: public Slave{ //2. implementation of Slave
	public:
	BubbleSort(vector<int> vec, Master *master):Slave(master){v=vec;}
	void doSort();
};
class MergeSort: public Slave{ //3. implementation of slave
	public:
	MergeSort(vector<int> vec, Master *master):Slave(master){v=vec;}
	void doSort();
	vector<int> mergesort(vector<int>);
	vector<int> merge(vector<int> links, vector<int> rechts);
};

 class MyThread : public QThread {//threads controlled by the master
 	private:
		Slave *slave;
	public:
		MyThread(Slave* s){slave= s;}
	protected:
		void run();
};
