Friday, May 11, 2012

Tech Review Software Engineering: Thursday, May 10, 2012

Java - TreeMap with Comparator

http://www.java-samples.com/showtutorial.php?tutorialid=371
  • OK example
  • another example
  • RepastEdge<T>
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
  • interface definition

Java - Class WattsBetaSmallWorldGenerator



Java - Class RepastEdge<T>



Java - for each loop Example
  • for (String city : cities)


No comments:

Post a Comment