Ejemplo n.º 1
0
        internal static Stepper <Node> BuildPath <AlgorithmNode, Node, Numeric>(BaseAlgorithmNode <AlgorithmNode, Node> node)
            where AlgorithmNode : BaseAlgorithmNode <AlgorithmNode, Node>
        {
            PathNode <Node> start = BuildPathRecursive <AlgorithmNode, Node, Numeric>(node, out PathNode <Node> end);

            return(step =>
            {
                PathNode <Node> current = start;
                while (current != null)
                {
                    step(current.Value);
                    current = current.Next;
                }
            });
        }
Ejemplo n.º 2
0
 internal static PathNode <Node> BuildPathRecursive <AlgorithmNode, Node, Numeric>(BaseAlgorithmNode <AlgorithmNode, Node> currentNode, out PathNode <Node> currentPathNode)
     where AlgorithmNode : BaseAlgorithmNode <AlgorithmNode, Node>
 {
     if (currentNode.Previous == null)
     {
         PathNode <Node> start = new PathNode <Node>()
         {
             Value = currentNode.Value
         };
         currentPathNode = start;
         return(start);
     }
     else
     {
         PathNode <Node> start = BuildPathRecursive <AlgorithmNode, Node, Numeric>(currentNode.Previous, out PathNode <Node> previous);
         currentPathNode = new PathNode <Node>()
         {
             Value = currentNode.Value
         };
         previous.Next = currentPathNode;
         return(start);
     }
 }