Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 public override int GetHashCode()
 {
     return(HashCodeHelper.CalculateGeneric(viewType, id));
 }