@@ -4,7 +4,7 @@ import java.util.Arrays;
|
|||||||
|
|
||||||
import redis.clients.util.SafeEncoder;
|
import redis.clients.util.SafeEncoder;
|
||||||
|
|
||||||
public class Tuple {
|
public class Tuple implements Comparable {
|
||||||
private byte[] element;
|
private byte[] element;
|
||||||
private Double score;
|
private Double score;
|
||||||
|
|
||||||
@@ -38,12 +38,22 @@ public class Tuple {
|
|||||||
return false;
|
return false;
|
||||||
} else if (!Arrays.equals(element, other.element))
|
} else if (!Arrays.equals(element, other.element))
|
||||||
return false;
|
return false;
|
||||||
if (Double.doubleToLongBits(score) != Double
|
|
||||||
.doubleToLongBits(other.score))
|
|
||||||
return false;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int compareTo(Tuple other) {
|
||||||
|
if (Arrays.equals(this.element, other.element))
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return this.score < other.getScore() ? -1 : 1;
|
||||||
|
}
|
||||||
|
public int compareTo(Object obj) {
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
throw new ClassCastException();
|
||||||
|
return compareTo((Tuple) obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public Tuple(String element, Double score) {
|
public Tuple(String element, Double score) {
|
||||||
super();
|
super();
|
||||||
this.element = SafeEncoder.encode(element);
|
this.element = SafeEncoder.encode(element);
|
||||||
|
|||||||
Reference in New Issue
Block a user