Java - TreeMap with Comparator
http://www.java-samples.com/showtutorial.php?tutorialid=371 class EdgeCompare implements Comparator
{
public int compare(Object a, Object b)
{
double weightA = (RepastEdge)a.getWeight();
double weightB = (RepastEdge)b.getWeight();
int returnVal;
if (weightA < weightB)
{
returnVal = 1;
}
else if (weightA == weightB)
{
returnVal = 0;
}
else
{
returnVal = -1;
}
return returnVal;
}
}
TreeSet ts = new TreeSet(new EdgeCompare);
- negative returned if a < b
- zero if a == b
- positive if a > b
List of Java Exceptions
Java - Arrays
Java - List Example
Java - Class WattsBetaSmallWorldGenerator
Java - Class RepastEdge<T>
Java - for each loop Example
- for (String city : cities)