package shortestPathGraphExperiments;

public class Pair implements Copyable<Pair>{
	int left;
	int right;
	public Pair(int x, int y) {
		if (x == y) throw new IllegalAccessError("DISASTER");
		if (x < y) {
			left = x;
			right = y;
		} else {
			left = y;
			right = x;
		}
	}
	
	@Override
	public String toString() {
		return "<" + left + ", " + right + ">";
	}
	
	public Pair copy() {
		return new Pair(left, right);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + left;
		result = prime * result + right;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Pair other = (Pair) obj;
		if (left != other.left)
			return false;
		if (right != other.right)
			return false;
		return true;
	}

	@Override
	public String print() {
		return this.toString();
	}
}
