Esempio n. 1
0
        private void DepthFirstVisitNodes(Func <FlowNode, bool> visitNodeCallback, FlowNode start)
        {
            Fx.Assert(visitNodeCallback != null, "This must be supplied since it stops us from infinitely looping.");

            List <FlowNode>  connected = new List <FlowNode>();
            Stack <FlowNode> stack     = new Stack <FlowNode>();

            if (start == null)
            {
                return;
            }
            stack.Push(start);
            while (stack.Count > 0)
            {
                FlowNode current = stack.Pop();

                if (current == null)
                {
                    continue;
                }

                if (visitNodeCallback(current))
                {
                    connected.Clear();
                    current.GetConnectedNodes(connected);

                    for (int i = 0; i < connected.Count; i++)
                    {
                        stack.Push(connected[i]);
                    }
                }
            }
        }
Esempio n. 2
0
        private void DepthFirstVisitNodes(Func <FlowNode, bool> visitNodeCallback, FlowNode start)
        {
            List <FlowNode>  connections = new List <FlowNode>();
            Stack <FlowNode> stack       = new Stack <FlowNode>();

            if (start != null)
            {
                stack.Push(start);
                while (stack.Count > 0)
                {
                    FlowNode arg = stack.Pop();
                    if ((arg != null) && visitNodeCallback(arg))
                    {
                        connections.Clear();
                        arg.GetConnectedNodes(connections);
                        for (int i = 0; i < connections.Count; i++)
                        {
                            stack.Push(connections[i]);
                        }
                    }
                }
            }
        }