xpathfinder.cpp

来自「这是一个用C++编写的公交车查询系统」· C++ 代码 · 共 54 行

CPP
54
字号

#include "StdAfx.h"

#include "XPathfinder.h"

#include <vector>
#include <algorithm>
#include <functional>      // For greater<int>( )
using namespace std;

XPathFinder::XPathFinder ()
{
	lines = XMapCtrl::lines;
	lines.BuildStations(stations);
}

XPathFinder::~XPathFinder ()
{
}

vector<XPath> XPathFinder::Find(CString station1, CString station2, int type)
{
	vector<XPath> paths;

	XStation* pStation1 = stations.Find (station1);
	XStation* pStation2 = stations.Find (station2);

	if (pStation1 && pStation2)
	{
		//1, 找直达线路
		vector<CString> nonstopLines;
		set_intersection (pStation1->lines.begin(), pStation1->lines.end(),
			pStation2->lines.begin(), pStation2->lines.end(), nonstopLines.begin());

		if (nonstopLines.size () > 0 )
		{
		}
		else //2, 经过一个中转站
		{
			vector<CString> stations1, stations2, stations3;

			lines.Merge (pStation1->lines, stations1);
			lines.Merge (pStation2->lines, stations2);

			set_intersection (stations1.begin(), stations1.end(),
				stations2.begin(), stations2.end(), stations3.begin());


		}
	}

	return paths;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?