Accord.MachineLearning.DecisionTrees.DecisionTreeTraversal.GetNextSibling C# (CSharp) Method

GetNextSibling() static private method

static private GetNextSibling ( int>.Dictionary cursors, Accord.MachineLearning.DecisionTrees.DecisionNode node ) : Accord.MachineLearning.DecisionTrees.DecisionNode
cursors int>.Dictionary
node Accord.MachineLearning.DecisionTrees.DecisionNode
return Accord.MachineLearning.DecisionTrees.DecisionNode
        internal static DecisionNode GetNextSibling(Dictionary<DecisionNode, int> cursors, DecisionNode node)
        {
            var parent = node.Parent;

            if (parent == null) return null;

            // Get current node index
            int index;
            if (!cursors.TryGetValue(node, out index))
                cursors[node] = index = 0;

            int nextIndex = index + 1;
            if (nextIndex < parent.Branches.Count)
            {
                var sibling = parent.Branches[nextIndex];
                cursors[sibling] = nextIndex;
                return sibling;
            }

            return null;
        }