X-Git-Url: https://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=tim%2Fprune%2Fcorrelate%2FTimeIndexPair.java;h=775b151ac32e92005ae8ca005ba1b8e67ebf5aba;hp=50305d44186892ec460fc8249678bd32acf4e9ca;hb=54b9d8bc8f0025ccf97a67d9dd217ef1f9cf082f;hpb=52bf9e8686c916be37a26a0b75340393d4478b05 diff --git a/tim/prune/correlate/TimeIndexPair.java b/tim/prune/correlate/TimeIndexPair.java index 50305d4..775b151 100644 --- a/tim/prune/correlate/TimeIndexPair.java +++ b/tim/prune/correlate/TimeIndexPair.java @@ -4,7 +4,7 @@ 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 +public class TimeIndexPair implements Comparable { /** Time as long */ private long _time = 0L; @@ -37,9 +37,20 @@ public class TimeIndexPair implements Comparable * Compare two TimeIndexPair objects * @see java.lang.Comparable#compareTo(java.lang.Object) */ - public int compareTo(Object inOther) + public int compareTo(TimeIndexPair inOther) { - TimeIndexPair other = (TimeIndexPair) inOther; - return (int) (_time - other._time); + 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; } }