MCPcopy Index your code
hub / github.com/benfry/processing4 / compare

Method compare

core/src/processing/data/Table.java:4434–4466  ·  view source on GitHub ↗
(int index1, int index2)

Source from the content-addressed store, hash-verified

4432 }
4433
4434 @Override
4435 public int compare(int index1, int index2) {
4436 int a = reverse ? order[index2] : order[index1];
4437 int b = reverse ? order[index1] : order[index2];
4438
4439 switch (getColumnType(column)) {
4440 case INT:
4441 return getInt(a, column) - getInt(b, column);
4442 case LONG:
4443 long diffl = getLong(a, column) - getLong(b, column);
4444 return diffl == 0 ? 0 : (diffl < 0 ? -1 : 1);
4445 case FLOAT:
4446 float difff = getFloat(a, column) - getFloat(b, column);
4447 return difff == 0 ? 0 : (difff < 0 ? -1 : 1);
4448 case DOUBLE:
4449 double diffd = getDouble(a, column) - getDouble(b, column);
4450 return diffd == 0 ? 0 : (diffd < 0 ? -1 : 1);
4451 case STRING:
4452 String string1 = getString(a, column);
4453 if (string1 == null) {
4454 string1 = ""; // avoid NPE when cells are left empty
4455 }
4456 String string2 = getString(b, column);
4457 if (string2 == null) {
4458 string2 = "";
4459 }
4460 return string1.compareToIgnoreCase(string2);
4461 case CATEGORY:
4462 return getInt(a, column) - getInt(b, column);
4463 default:
4464 throw new IllegalArgumentException("Invalid column type: " + getColumnType(column));
4465 }
4466 }
4467
4468 @Override
4469 public void swap(int a, int b) {

Callers

nothing calls this directly

Calls 6

getColumnTypeMethod · 0.95
getIntMethod · 0.95
getLongMethod · 0.95
getFloatMethod · 0.95
getDoubleMethod · 0.95
getStringMethod · 0.95

Tested by

no test coverage detected