public static long DoTraverseListTest(ParentNode parentNode, int repeatCount) { var sw = new Stopwatch(); sw.Start(); var testlist = new List<ParentNode>(); parentNode.TraversePairwise((p, d) => { testlist.Add(d); return true; }); sw.Stop(); return sw.ElapsedMilliseconds; }
private static int LargestChildCount(ParentNode tree, int largestCountSoFar = -1) { var count = Math.Max(largestCountSoFar, tree.Children.Count); foreach (var n in tree.Children) { count = LargestChildCount(n, count); } return count; }
private static void DumpTree(ParentNode tree, int indent = 0) { foreach (var n in tree.Children) { Console.WriteLine("{0}{1} [{2}] {{{3}}}", "".PadLeft(indent, ' '), n.Name, n.Count, n.Children.Count); DumpTree(n, indent + 1); } }