public class Pair implements Comparable<Pair> {

	private final int   key;
	private final float value;
	
	public Pair(int key, float value) {
		this.key   = key;
		this.value = value;
	}
	
	public int getKey()
	{
		return key;
	}
	
	public float getValue()
	{
		return value;
	}
	
	@Override
	public int compareTo(Pair that) {
        int cmp =  Float.compare(this.value, that.value);
        if (cmp < 0)
            return -1;
        else if (cmp > 0)
            return 1;
        else
            return 0;
	}

    // is this Pair equal to x?
    public boolean equals(Object x) {
        if (x == this) return true;
        if (x == null) return false;
        if (x.getClass() != this.getClass()) return false;
        
        Pair that = (Pair) x;
        return (this.value == that.value);
    }


    public int hashCode() {
        int hash = 17;

        hash = 31*hash + ((Integer) key).hashCode();
        hash = 31*hash + ((Float) value).hashCode();

        return hash;
    }
}