| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
package uk.me.parabola.imgfmt.app.srt; |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
public class IntegerSortKey<T> implements SortKey<T> { |
| 21 |
private final T object; |
| 22 |
private final int val; |
| 23 |
private final int second; |
| 24 |
|
| 25 |
public IntegerSortKey(T object, int val, int second) { |
| 26 |
this.object = object; |
| 27 |
this.val = val; |
| 28 |
this.second = second; |
| 29 |
} |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
public T getObject() { |
| 35 |
return object; |
| 36 |
} |
| 37 |
|
| 38 |
public int compareTo(SortKey<T> o) { |
| 39 |
IntegerSortKey<T> other = (IntegerSortKey<T>) o; |
| 40 |
if (val == other.val) { |
| 41 |
if (second == other.second) |
| 42 |
return 0; |
| 43 |
else if (second < other.second) |
| 44 |
return -1; |
| 45 |
else |
| 46 |
return 1; |
| 47 |
} |
| 48 |
else if (val < other.val) |
| 49 |
return -1; |
| 50 |
else |
| 51 |
return 1; |
| 52 |
} |
| 53 |
} |