XPathFinder.cpp
上传用户:yokoluohf
上传日期:2013-02-25
资源大小:769k
文件大小:1k
- #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;
- }