Esempio n. 1
0
 public override string ToString()
 {
     if (Prime == false)      // If node is not in an augmented list
     {
         return($"[FC Node - dim: {Dimension} , index: {Index}, {BaseCoordNode}]");
     }
     else if (PreviousNode == null && NextNode == null)
     {
         return($"[FC Node - dim: {Dimension}, index: {Index}, " +
                $"{BaseCoordNode}, next: empty, prev: empty]");
     }
     else if (PreviousNode == null && NextNode != null)
     {
         return($"[FC Node - dim: {Dimension}, index: {Index}, {BaseCoordNode}" +
                $", next: {NextNode.GetData()}, prev: empty]");
     }
     else if (PreviousNode != null && NextNode == null)
     {
         return($"[FC Node - dim: {Dimension}, index: {Index}, {BaseCoordNode}, " +
                $"next: empty, prev: {PreviousNode.GetData()}]");
     }
     else
     {
         return($"[FC Node - dim: {Dimension}, index: {Index}, {BaseCoordNode}, " +
                $"next: {NextNode.GetData()}, prev: {PreviousNode.GetData()}]");
     }
 }
Esempio n. 2
0
        private FCNode FindNodeFromPointerRange(FCNode dataNode, int targetDimension)
        {
            /**
             * Find and search a range of indices for the FCNode with the target data value
             * at the target dimension.
             *
             * Finding range:
             *  DataNode comes from targetDimension - 1 . DataNode contains pointers to
             *  FCNodes from the augmented list of the next dimension (TargetDimension).
             *  The search range is between the locations of DataNode.prev and
             *  DataNode.next in the augmented list in the TargetDimension. */

            int    targetData = dataNode.GetData();
            FCNode prevNode   = dataNode.GetPrevPointer();
            FCNode nextNode   = dataNode.GetNextPointer();

            // Find range
            int lowRange, highRange;
            int targetDimIndex = targetDimension - 1;

            if (prevNode == null)
            {
                lowRange = 0;
            }
            else
            {
                lowRange = prevNode.GetPreviouslyAugmentedIndex();
            }

            if (nextNode == null)
            {
                highRange = NodeMatrixPrime[targetDimIndex].Length;
            }
            else
            {
                highRange = nextNode.GetPreviouslyAugmentedIndex();
            }

            IEnumerable <int> range = Enumerable.Range(lowRange, highRange - lowRange);

            // Search range
            bool found = false;

            foreach (int j in range)
            {
                dataNode = NodeMatrixPrime[targetDimIndex][j];

                if (TargetNodeCheck(dataNode, targetData, targetDimension))
                {
                    found = true;
                    break;
                }
            }

            if (!(found))
            {
                throw new Exception("Can't find node with data " + targetData +
                                    " in dimension: " + targetDimension +
                                    " during fractional cascading search");
            }
            return(dataNode);
        }
Esempio n. 3
0
 private bool TargetNodeCheck(FCNode node, int targetData, int targetDimension)
 {
     return(node != null &&
            node.GetData() == targetData &&
            node.GetDim() == targetDimension);
 }