1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
package tim.prune.correlate;
/**
* Simple class to hold a time and an index.
* Used in a TreeSet for calculating median time difference
*/
public class TimeIndexPair implements Comparable<TimeIndexPair>
{
/** Time as long */
private long _time = 0L;
/** Index as int */
private int _index = 0;
/**
* Constructor
* @param inTime time as long
* @param inIndex index as int
*/
public TimeIndexPair(long inTime, int inIndex)
{
_time = inTime;
_index = inIndex;
}
/**
* @return the index
*/
public int getIndex()
{
return _index;
}
/**
* Compare two TimeIndexPair objects
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
public int compareTo(TimeIndexPair inOther)
{
return (int) (_time - inOther._time);
}
/**
* Override equals method to match compareTo
*/
public boolean equals(Object inOther)
{
if (inOther instanceof TimeIndexPair) {
TimeIndexPair otherPair = (TimeIndexPair) inOther;
return _time == otherPair._time;
}
return false;
}
}
|