package bandits;

/**
 * Used to store (int,double) pairs
 * @author Sean McCullough
 *
 */
public class Pair implements Comparable<Pair>
{
	private int index;
	private double value;
	
	/**
	 * Initializes Pair with index
	 * @param index Index of new pair
	 */
	public Pair(int index)
	{
		this.index = index;
		value = 0.0;
	}
	/**
	 * Initializes new Pair with index, value
	 * @param index index of new Pair
	 * @param value value of new Pair
	 */
	public Pair(int index, double value)
	{
		this.index = index;
		this.value = value;
	}

	@Override
	public int compareTo(Pair other) 
	{
		return Double.compare(this.value, other.value);
	}
	
	public boolean equals(Object obj)
	{
		if(obj.getClass().equals(Pair.class) 
				&& ((Pair)obj).index == this.index) 
			return true;
		return false;
	}
	
	/**
	 * Returns this Pair's index
	 * @return index
	 */
	public int index() { return index; }
	
	/**
	 * Returns this Pair's value
	 * @return value
	 */
	public double value() { return value; }
	
	/**
	 * Changes this Pair's value
	 * @param value New value
	 */
	public void newValue(double value) { this.value = value; }
}