public void XYZ_MatchingValues_AreEqual() { var point1 = new XYZ(1, 2, 3); var point2 = new XYZ(1, 2, 3); Assert.AreEqual(point1, point2); Assert.AreEqual(point1.GetHashCode(), point2.GetHashCode()); }
public void XYZ_DifferentValues_AreNotEqual() { var point1 = new XYZ(1, 2, 3); var point2 = new XYZ(4, 5, 6); Assert.AreNotEqual(point1, point2); Assert.AreNotEqual(point1.GetHashCode(), point2.GetHashCode()); }
/// <summary> /// 优化点 /// </summary> public void OptimizePoints() { Dictionary <int, int> dictionary = new Dictionary <int, int>(); IList <XYZ> list = new List <XYZ>(Points.Count); for (int i = 0; i < Indices.Count; i++) { XYZ xYZ = Points[Indices[i]]; int hashCode = xYZ.GetHashCode(); if (dictionary.ContainsKey(hashCode)) { Indices[i] = dictionary[hashCode]; } else { list.Add(xYZ); int value = list.Count - 1; dictionary[hashCode] = value; Indices[i] = value; } } Points = list; }
public override int GetHashCode() { return(base.GetHashCode() ^ _color.GetHashCode()); }