#ifndef EXCHANGE_H
#define EXCHANGE_H

#pragma once

#include "Header.h"
#include "Utils.h"
/**
*	\class Exchange.
*	\brief	Represents a exchange.
*/

class Exchange {

protected:

	int id;
	string type;								//"cycle", "chain"
	int weight;
	int length;
	vector<int> sequence;
	vector<int> visits;							//vertex visits
	unordered_map<int, int> traverses;			//arc traverses
	int vertexNumber;

	static int lastId;

public:
	
	//CONSTRUCTORS (default, parametrized, copy)
	Exchange();
	Exchange(const string& type, const int& weight, const int& length, const vector<int>& sequence, const int vertexNumber);
	Exchange(const Exchange& e);

	//DESTRUCTOR
	~Exchange();

	//OPERATORS OVERLOADING (assignment, equality, not equal to)
	Exchange& operator=(const Exchange& e);
	friend bool operator==(const Exchange& e1, const Exchange& e2);
	friend bool operator!=(const Exchange& e1, const Exchange& e2);

	//METHODS
	static void restartIds();
	void buildVisits();
	void buildTraverses();
	bool isVertexInExchange(const int& id) const;
	bool conflicts_with(const Exchange& e) const;
	//returns the first vertex (no source) in common between this and e, -1 if the intersection is empty
	int first_vertex_in_common(const Exchange& e) const;
	unordered_set<int> vertices_in_common(const Exchange& e) const;

	//GET METHODS
	const int& getId() const;
	const string& getType() const;
	const int& getWeight() const;
	const int& getLength() const;
	const vector<int>& getSequence() const;
	int getVisit(const int& id) const;
	int getTraverses(const int& id1, const int& id2) const;

	//SET METHODS

	const string toString() const;

};

#endif //EXCHANGE_H