I just generalized the iterator implemented in my previous blog post to non-recursively iterate any object tree. static IEnumerable<T> Iterate<T>(T rootNode, Func<T, IEnumerable<T>> getChildren) { var stack = new Stack<T>(); stack.Push(rootNode); while (stack.Count > 0) { T node = stack.Pop(); yield return node; IEnumerable<T> childNodes = getChildren(node); foreach (var childNode in childNodes) stack.Push(childNode); } }
About
Klinkby
- Failed to get a glimpse of @MedinaMusic through a swarm of 30.000 drunk teens in #Tivoli - twitted 1 week ago
- .@SPSaturday_CPH is awfully quiet, I'm wondering (hoping) if there will be a #spscph this year? /cc: @sharepointdk @jesperpersson @meikdk - twitted 1 week ago
- Danish minister of justice won't answer if #NemId is a backdoor to citizen's computers ft.dk/samling/20111/… @smbrix #dkpol #stasi - twitted 2 weeks ago
- Hey birch get outta my face astma-allergi.dk/detlavervi/dag… #achoo - twitted 2 weeks ago
-
Top Posts
Tag Cloud
-
Bookmarked