public int AddArc(IList <CoordPoint> arc) { int key = Math.Abs(HashCodeHelper.CalculateGeneric(arc[arc.Count - 1])) % this.hashTableSize; int chainId = hashTable[key]; int arcId = this.arcs.Count; hashTable[key] = arcId; arcs.Add(arc); chainIds.Add(chainId); return(arcId); }
IList <int> InitializeHashChains(IList <CoordPoint> polygonsPoints) { int hashTableSize = (int)Math.Floor(polygonsPoints.Count * 1.3); int[] hashTable = new int[hashTableSize]; int[] chainIds = new int[polygonsPoints.Count]; for (int i = 0; i < polygonsPoints.Count; ++i) { int key = Math.Abs(HashCodeHelper.CalculateGeneric(polygonsPoints[i])) % hashTableSize; int previousPointWithSameKeyIndex = hashTable[key] - 1; hashTable[key] = i + 1; chainIds[i] = previousPointWithSameKeyIndex >= 0 ? previousPointWithSameKeyIndex : i; } return(chainIds); }
internal bool ContainsArcNeighbor(int start, int end, int next) { int key = Math.Abs(HashCodeHelper.CalculateGeneric(this.points[start])) % this.hashTableSize; int arcId = hashTable[key]; while (arcId != -1) { int arcLength = arcs[arcId].Count; if (arcs[arcId][0] == points[end] && arcs[arcId][arcLength - 1] == points[start] && arcs[arcId][arcLength - 2] == points[next]) { return(true); } arcId = chainIds[arcId]; } return(false); }
public override int GetHashCode() { return(HashCodeHelper.CalculateGeneric(viewType, id)); }