I need to implement some kind table-like data structure that stores info like this in Java:
+--------+-------+-----+
| sij | i | j |
+--------+-----
If I understand your question right, all you need is a Comparable
class to represent a row.
public static class Row
implements Comparable {
public Row(int sij, int i, int j) {
this.sij = sij;
this.i = i;
this.j = j;
}
public int compareTo(Row other) {
return Integer.valueOf(sij).compareTo(other.sij);
}
public final int sij;
public final int i;
public final int j;
}
You can then populate a List
with instances of Row
and use Collections.sort
to sort it.