|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectlogist.topology.Topology.City
public class Topology.City
This class provides the following shortcut to iterate over all neighbors of this city:
for (City neighbor : myCity) ...
| Field Summary | |
|---|---|
int |
id
|
java.lang.String |
name
|
int |
xPos
|
int |
yPos
|
| Method Summary | |
|---|---|
double |
distanceTo(Topology.City to)
Returns the distance in kilometers from this city to another city. |
long |
distanceUnitsTo(Topology.City to)
Returns the distance in 'units' from this city to another city. |
boolean |
equals(java.lang.Object that)
|
int |
hashCode()
|
boolean |
hasNeighbor(Topology.City city)
Determines whether another city is a neighbor of this city |
java.util.Iterator<Topology.City> |
iterator()
An iterator over all neighboring cities of this city. |
java.util.List<Topology.City> |
neighbors()
Returns the list of all neighbors. |
java.util.List<Topology.City> |
pathTo(Topology.City to)
Returns the list of cities on the shortest path from this city to another city. |
Topology.City |
randomNeighbor(java.util.Random rnd)
Returns a random neighbor of this city. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public final int id
public final int xPos
public final int yPos
public final java.lang.String name
| Method Detail |
|---|
public boolean equals(java.lang.Object that)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic java.util.List<Topology.City> neighbors()
public boolean hasNeighbor(Topology.City city)
city - public java.util.Iterator<Topology.City> iterator()
iterator in interface java.lang.Iterable<Topology.City>public long distanceUnitsTo(Topology.City to)
This is the preferred unit of measurement for the simulation.
Measurespublic double distanceTo(Topology.City to)
public java.util.List<Topology.City> pathTo(Topology.City to)
The list does not include the first city on the path, but it does include the last city. I.e. if the shortest path from A to D is A -> B -> C -> D then the list [B,C,D] is returned.
to - the destinationpublic Topology.City randomNeighbor(java.util.Random rnd)
rnd - a random number generator
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||