// note that we add the cluster node // instead of the cluster. internal bool MergeClusters_(int vertex1, int vertex2, bool update_hash) { int cluster_1 = m_shape.GetUserIndex(vertex1, m_new_clusters); int cluster_2 = m_shape.GetUserIndex(vertex2, m_new_clusters); System.Diagnostics.Debug.Assert((cluster_1 != com.epl.geometry.StridedIndexTypeCollection.ImpossibleIndex2())); System.Diagnostics.Debug.Assert((cluster_2 != com.epl.geometry.StridedIndexTypeCollection.ImpossibleIndex2())); if (cluster_1 == -1) { cluster_1 = m_clusters.CreateList(); m_clusters.AddElement(cluster_1, vertex1); m_shape.SetUserIndex(vertex1, m_new_clusters, cluster_1); } if (cluster_2 == -1) { m_clusters.AddElement(cluster_1, vertex2); } else { m_clusters.ConcatenateLists(cluster_1, cluster_2); } // ensure only single vertex refers to the cluster. m_shape.SetUserIndex(vertex2, m_new_clusters, com.epl.geometry.StridedIndexTypeCollection.ImpossibleIndex2()); // merge cordinates bool res = MergeVertices_(vertex1, vertex2); if (update_hash) { int hash = m_hash_function.Calculate_hash_from_vertex(vertex1); m_shape.SetUserIndex(vertex1, m_hash_values, hash); } return(res); }
// Adds new element to the hash table. public int AddElement(int element, int hash) { int bit_bucket = hash % (m_bit_filter.Length << 5); m_bit_filter[(bit_bucket >> 5)] |= (1 << (bit_bucket & unchecked ((int)(0x1F)))); int bucket = hash % m_hashBuckets.Size(); int list = m_hashBuckets.Get(bucket); if (list == -1) { list = m_lists.CreateList(); m_hashBuckets.Set(bucket, list); } int node = m_lists.AddElement(list, element); return(node); }