using System; using System.Collections.Generic; namespace HeuristicLab.Algorithms.GraphRouting { public class Pair { public T First { get; private set; } public T Second { get; private set; } public Pair(T first, T second) { First = first; Second = second; } public override int GetHashCode() { return First.GetHashCode() ^ Second.GetHashCode(); } public override bool Equals(object other) { Pair pair = other as Pair; if (pair == null) { return false; } return (this.First.Equals(pair.First) && this.Second.Equals(pair.Second)); } } class PairComparer : IComparer> where T : IComparable { public int Compare(Pair x, Pair y) { if (x.First.CompareTo(y.First) < 0) { return -1; } else if (x.First.CompareTo(y.First) > 0) { return 1; } else { return x.Second.CompareTo(y.Second); } } } }