|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.waldura.tw.DenseRoutesMap
class DenseRoutesMap
This map stores routes in a matrix, a nxn array. It is most useful when there are lots of routes, otherwise using a sparse representation is recommended.
Field Summary | |
---|---|
private int[][] |
distances
|
Constructor Summary | |
---|---|
DenseRoutesMap(int numCities)
|
Method Summary | |
---|---|
void |
addDirectRoute(City start,
City end,
int distance)
Link two cities by a direct route with the given distance. |
java.util.List<City> |
getDestinations(City city)
Get the list of cities that can be reached from the given city. |
int |
getDistance(City start,
City end)
Get the value of a segment. |
RoutesMap |
getInverse()
|
java.util.List<City> |
getPredecessors(City city)
Get the list of cities that lead to the given city. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final int[][] distances
Constructor Detail |
---|
DenseRoutesMap(int numCities)
Method Detail |
---|
public void addDirectRoute(City start, City end, int distance)
addDirectRoute
in interface RoutesMap
public int getDistance(City start, City end)
RoutesMap
getDistance
in interface RoutesMap
public java.util.List<City> getDestinations(City city)
RoutesMap
getDestinations
in interface RoutesMap
public java.util.List<City> getPredecessors(City city)
RoutesMap
getPredecessors
in interface RoutesMap
public RoutesMap getInverse()
getInverse
in interface RoutesMap
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |