www.pudn.com > 20065291434354190.rar > XPathFinder.cpp
#include "StdAfx.h" #include "XPathfinder.h" #include#include #include // For greater ( ) using namespace std; XPathFinder::XPathFinder () { lines = XMapCtrl::lines; lines.BuildStations(stations); } XPathFinder::~XPathFinder () { } vector XPathFinder::Find(CString station1, CString station2, int type) { vector paths; XStation* pStation1 = stations.Find (station1); XStation* pStation2 = stations.Find (station2); if (pStation1 && pStation2) { //1, 找直达线路 vector nonstopLines; set_intersection (pStation1->lines.begin(), pStation1->lines.end(), pStation2->lines.begin(), pStation2->lines.end(), nonstopLines.begin()); if (nonstopLines.size () > 0 ) { } else //2, 经过一个中转站 { vector 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; }