/// <summary> /// Removes all duplicates from this list. It also removes ALL null references. /// </summary> public int CullDuplicates() { FuzzyNode2Comparer comparer = new FuzzyNode2Comparer(1E-12); SortedDictionary <Node2, int> sortedDictionary = new SortedDictionary <Node2, int>(comparer); int num = 0; int num2 = 0; int num3 = m_nodes.Count - 1; for (int i = 0; i <= num3; i++) { if (m_nodes[i] == null || sortedDictionary.ContainsKey(m_nodes[i])) { num2++; continue; } sortedDictionary.Add(m_nodes[i], 1); m_nodes[num] = m_nodes[i]; num++; } if (num > 0) { m_nodes.RemoveRange(num, m_nodes.Count - num); } return(num2); }
/// <summary> /// Set all duplicate nodes to NULL /// </summary> public int NullifyDuplicates() { FuzzyNode2Comparer comparer = new FuzzyNode2Comparer(1E-12); SortedDictionary <Node2, int> sortedDictionary = new SortedDictionary <Node2, int>(comparer); int num = 0; int num2 = m_nodes.Count - 1; for (int i = 0; i <= num2; i++) { if (m_nodes[i] != null) { if (sortedDictionary.ContainsKey(m_nodes[i])) { num++; m_nodes[i] = null; } else { sortedDictionary.Add(m_nodes[i], 1); } } } return(num); }