偶5月份写的公交换乘算法: import java.sql.Connection; public class BusTransfer { private String start = null;// 出发地 private String whither = null;// 目标地 private List schedule = null;// 用于缓存列车时刻表。 private HashMap <String, ArrayList> stationsOfLine = null; // 所有公交线路,每个list存储该线路经过的所有车站。 private HashMap <String, ArrayList> linesOfStation = null;// 所有车站,每个list中存储通过该车站的所有车次。 // private ArrayList <String> startLine = new ArrayList <String>();// // private ArrayList <String> whitherLine = new ArrayList <String>();// private ArrayList <Map> firLineStaList = new ArrayList <Map>(); private ArrayList <Map> secLineStaList = new ArrayList <Map>(); public BusTransfer(String start, String whither) { try { private HashMap <String, ArrayList> getStationsOfLine() { Iterator it = schedule.iterator(); // 迭代器 temp = (String) map.get("busLine"); } else { private HashMap getLinesOfStation() { Iterator it = schedule.iterator(); // 迭代器 temp = (String) map.get("up"); } else { /** ArrayList station; if (firTrainLine != null) { // 取出车次trainNo经过的所有站点信息 Map map = (Map) it.next();// trainNo's map. if (secTrainLine != null) { station = stationsOfLine.get(trainNo); Map map = (Map) it.next(); if (i < transferStaNo) { secLineStaList.add(map); /** ArrayList <Map> crossLineList = new ArrayList <Map>();// 相交线路的集合,即是所有的换乘方法的集合 if (lsStart != null && !lsStart.isEmpty() && lsEnd != null for (Map <String, String> mapStart : lsStart) { // 将相交线路信息存入crossLine,存储某一个具体的换乘方法 // 把第一次要做到车次放如crossLine // crossLine.put("transferSta",(String)startInf.get("up")); } else { return crossLineList; private boolean IsInTheSameCity(String station1, String station2) { if (station1.contains(station2) | | station2.contains(station1)) { } public ArrayList <Map> getSchemaOfTransfer() { public static void main(String[] args) { // System.out.println(tb.secLineStaList.size()); private Connection getConnection() { private void closeConnection(Connection conn) throws Exception { private List executeQuery(String sql) throws Exception { System.out.println(sql); rs = stmt.executeQuery(sql); ResultSetMetaData rsmd = rs.getMetaData(); |
公交算法2
最新推荐文章于 2020-07-18 22:10:21 发布
※
公交换乘算法