コード例 #1
0
 @Override
 public int compare(GraphObject t0, GraphObject t1) {
   long x0 = t1.getReturnTime(t0);
   long x1 = t0.getReturnTime(t1);
   if (x0 == x1) { // either same or == 0
     long d = t0.getStartTime() - t1.getStartTime();
     if (d < 0) return -1;
     else if (d > 0) return 1;
     else if (t0.getName() == null) return -1;
     else if (t1.getName() == null) return 1;
     else return t0.getName().compareTo(t1.getName());
   } else if (x0 == 0) return -1;
   else if (x1 == 0) return 1;
   else if (x0 < x1) return 1;
   else return -1;
 }
コード例 #2
0
 long getReturnTime(GraphObject to) {
   for (GraphLink lnk : out_links) {
     if (lnk.getType() == LinkType.RETURN) {
       GraphObject go = lnk.getToObject();
       if (go == to) return lnk.getTime();
       else {
         long rt = go.getReturnTime(to);
         if (rt != 0) return Math.min(lnk.getTime(), rt);
       }
     }
   }
   return 0;
 }