#pragma warning (disable:4786)
#include "test.hpp"
#include "airailpath.hpp"


my_vector<int> fred;
my_vector<CRailLink *> fred1;
my_vector<CRailLink> fred2;

using namespace std;

CRailNode::CRailNode (CPoint loc)
{
	m_Location = loc;
}

CRailNode::~CRailNode (void)
{
}

CRailGraph::CRailGraph (void)
{
	m_Nodes.clear ();
	m_Links.clear ();
}

CRailGraph::~CRailGraph (void)
{
	vector<CRailLink *>::iterator iter1;
	map<int,CRailNode *>::iterator iter2;

	iter1 = m_Links.begin ();
	while (iter1 != m_Links.end ())
	{
		delete (*iter1);
		(*iter1) = NULL;
		iter1++;
	}
	iter2 = m_Nodes.begin ();
	while (iter2 != m_Nodes.end ())
	{
		delete (*iter2).second;
		(*iter2).second = NULL;
		iter2++;
	}
}

void CRailGraph::AddNode (CRailNode *node,int id)
{
	assert (m_Nodes.find (id) == m_Nodes.end ());
	m_Nodes[id] = node;
}

void CRailGraph::AddLink (CRailLink *link)
{
	m_Links.push_back (link);
}

float CRailGraph::Connect (CRailNode *src,CRailNode *dest) const
{
	vector<CRailLink *>::const_iterator iter;
	
	iter = m_Links.begin ();
	while (iter != m_Links.end ())
	{
		if (((*iter)->Location(0) == dest) && ((*iter)->Location(1) == src))
			return (*iter)->Weight ();
		else if (((*iter)->Location(0) == src) && ((*iter)->Location(1) == dest))
			return (*iter)->Weight ();
		else
			iter++;
	}
	return 0.0;
}

CRailPath::CRailPath (CPoint start,CPoint end)
{
	m_Start = start;
	m_End = end;
	m_CurrentLink = 0;
}
CRailPath::~CRailPath (void)
{
	m_Links.clear ();
}

void CRailPath::CalcPath (void)
{
}

