|
|
@ -63,25 +63,13 @@ public abstract class kelondroAbstractOrder implements kelondroOrder {
|
|
|
|
return cardinal(key) / d;
|
|
|
|
return cardinal(key) / d;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int compareI(byte[] a, byte[] b) {
|
|
|
|
|
|
|
|
if (zero == null) return compare(a, b);
|
|
|
|
|
|
|
|
// we have an artificial start point. check all combinations
|
|
|
|
|
|
|
|
int az = compare(a, zero); // -1 if a < z; 0 if a == z; 1 if a > z
|
|
|
|
|
|
|
|
int bz = compare(b, zero); // -1 if b < z; 0 if b == z; 1 if b > z
|
|
|
|
|
|
|
|
if ((az == 0) && (bz == 0)) return 0;
|
|
|
|
|
|
|
|
if (az == 0) return -1;
|
|
|
|
|
|
|
|
if (bz == 0) return 1;
|
|
|
|
|
|
|
|
if (az == bz) return compare(a, b);
|
|
|
|
|
|
|
|
return bz;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int compare(Object a, Object b) {
|
|
|
|
public int compare(Object a, Object b) {
|
|
|
|
if ((a instanceof byte[]) && (b instanceof byte[])) {
|
|
|
|
if ((a instanceof byte[]) && (b instanceof byte[])) {
|
|
|
|
return compareI((byte[]) a, (byte[]) b);
|
|
|
|
return compare((byte[]) a, (byte[]) b);
|
|
|
|
} else if ((a instanceof Node) && (b instanceof Node)) {
|
|
|
|
} else if ((a instanceof Node) && (b instanceof Node)) {
|
|
|
|
return compareI(((Node) a).getKey(), ((Node) b).getKey());
|
|
|
|
return compare(((Node) a).getKey(), ((Node) b).getKey());
|
|
|
|
} else if ((a instanceof String) && (b instanceof String)) {
|
|
|
|
} else if ((a instanceof String) && (b instanceof String)) {
|
|
|
|
return compareI(((String) a).getBytes(), ((String) b).getBytes());
|
|
|
|
return compare(((String) a).getBytes(), ((String) b).getBytes());
|
|
|
|
} else
|
|
|
|
} else
|
|
|
|
throw new IllegalArgumentException("Object type or Object type combination not supported: a=" + a + ", b=" + b);
|
|
|
|
throw new IllegalArgumentException("Object type or Object type combination not supported: a=" + a + ", b=" + b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|