public int GetHashCode(UniqueBlockStructure <BlockTypeTable> obj) { //TODO: This hash function is not very good, see http://stackoverflow.com/a/1079419/410020 var table = (BlockTypeTable)obj; int result = 17; var stringBlockComparer = new StringBlock.StringBlockEqualityComparer(); unchecked { foreach (var item in table) { result = result * 31 + stringBlockComparer.GetHashCode(item.Item1); result = result * 31 + item.Item2; } } return(result); }
public bool Equals(UniqueBlockStructure <BlockTypeTable> x, UniqueBlockStructure <BlockTypeTable> y) { var tableX = (BlockTypeTable)x; var tableY = (BlockTypeTable)y; if (tableX.Count != tableY.Count) { return(false); } int count = tableX.Count; var stringBlockComparer = new StringBlock.StringBlockEqualityComparer(); for (int i = 0; i < count; i++) { Tuple <StringBlock, int> bX = tableX[i]; Tuple <StringBlock, int> bY = tableY[i]; if (!(stringBlockComparer.Equals(bX.Item1, bY.Item1) && bX.Item2 == bY.Item2)) { return(false); } } return(true); }