public class Arc
{
String startPoint;
String endPoint;
int distance;
Arc(String startPoint,String endPoint,int distance)
{
this.startPoint=startPoint;
this.endPoint=endPoint;
this.distance=distance;
}
public String getStartPoint()
{
return startPoint;
}
public String getEndPoint()
{
return endPoint;
}
public int getDistance()
{
return distance;
}
}
public class ArcCollections
{
private HashMap<String, HashMap<String, Integer>> outMap = new HashMap<String,HashMap<String,Integer>>();
private HashMap<String, Integer> inMap = new HashMap<String,Integer>();
public void addArc(Arc arc)
{
String st = arc.getStartPoint();
String end = arc.getEndPoint();
int dist = arc.getDistance();
inMap.put(end, dist);
outMap.put(st,inMap);
}
}
示例输入类似于:(即){source,{destination,distance}}
如何在指定的地图结构中插入这些值?因为在调试时inMap
仅产生null
值
从excel读取值并从main函数传递给对象,如下所示:
tmpArc = new Arc(tempFromCity,tempToCity,dist);