1 package tim.prune.correlate;
4 * Simple class to hold a time and an index.
5 * Used in a TreeSet for calculating median time difference
7 public class TimeIndexPair implements Comparable<TimeIndexPair>
10 private long _time = 0L;
12 private int _index = 0;
17 * @param inTime time as long
18 * @param inIndex index as int
20 public TimeIndexPair(long inTime, int inIndex)
37 * Compare two TimeIndexPair objects
38 * @see java.lang.Comparable#compareTo(java.lang.Object)
40 public int compareTo(TimeIndexPair inOther)
42 int compare = (int) (_time - inOther._time);
43 if (compare == 0) {compare = _index - inOther._index;}
48 * Override equals method to match compareTo
50 public boolean equals(Object inOther)
52 if (inOther instanceof TimeIndexPair) {
53 TimeIndexPair otherPair = (TimeIndexPair) inOther;
54 return _time == otherPair._time;