Пример #1
0
 @Override
 public int compareTo(Object o) {
   if (o instanceof DateAxisGraphLabel) {
     return Long.compare(this.date, ((DateAxisGraphLabel) o).getDate());
   }
   return 0;
 }
    /** {@inheritDoc} */
    @Override
    public int compareTo(CancelMessageId m) {
      int res = Long.compare(reqId, m.reqId);

      if (res == 0) res = m.nodeId.compareTo(nodeId);

      return res;
    }
Пример #3
0
 protected static int compare(Object lvalue, Object rvalue) throws DapException {
   if (lvalue instanceof String && rvalue instanceof String)
     return ((String) lvalue).compareTo((String) rvalue);
   if (lvalue instanceof Boolean && rvalue instanceof Boolean)
     return compare((Boolean) lvalue ? 1 : 0, (Boolean) rvalue ? 1 : 0);
   if (lvalue instanceof Double
       || lvalue instanceof Float
       || rvalue instanceof Double
       || rvalue instanceof Float) {
     double d1 = ((Number) lvalue).doubleValue();
     double d2 = ((Number) lvalue).doubleValue();
     return Double.compare(d1, d2);
   } else {
     long l1 = ((Number) lvalue).longValue();
     long l2 = ((Number) rvalue).longValue();
     return Long.compare(l1, l2);
   }
 }
  // suffix array in O(n*log^2(n))
  public static Integer[] suffixArray(CharSequence s) {
    int n = s.length();
    Integer[] sa = new Integer[n];
    int[] rank = new int[n];
    for (int i = 0; i < n; i++) {
      sa[i] = i;
      rank[i] = s.charAt(i);
    }
    for (int len = 1; len < n; len *= 2) {
      long[] rank2 = new long[n];
      for (int i = 0; i < n; i++)
        rank2[i] = ((long) rank[i] << 32) + (i + len < n ? rank[i + len] + 1 : 0);

      Arrays.sort(sa, (a, b) -> Long.compare(rank2[a], rank2[b]));

      for (int i = 0; i < n; i++)
        rank[sa[i]] = i > 0 && rank2[sa[i - 1]] == rank2[sa[i]] ? rank[sa[i - 1]] : i;
    }
    return sa;
  }
 /**
  * Compares the target to a timestamp.
  *
  * @param timestamp the timestamp to compare.
  * @return a negative integer, zero, or a positive integer as the target lies before, covering,
  *     or after than the timestamp.
  */
 public int compareToTimestamp(long timestamp) {
   return Long.compare(divPosition, timestamp / size);
 }
 @Override
 public int compare(VisorGgfsProfilerEntry a, VisorGgfsProfilerEntry b) {
   return Long.compare(a.timestamp, b.timestamp);
 }
Пример #7
0
 @Override
 public int compare(VisorLogFile f1, VisorLogFile f2) {
   return Long.compare(f2.lastModified(), f1.lastModified());
 }
Пример #8
0
 @Override
 public int compare(Event o1, Event o2) {
   return Long.compare(o1.localOrder(), o2.localOrder());
 }