Archives
-
Recursively Traversing IEnumerable<T>
Most of the samples I saw about traversing an IEnumerable<T> use recursion, this can cause some overload in the stack depending on the hierarchy depth. The version I propose use a Queue<T> to achieve the same; note that this is I a common algorithm named Breadth-first search, and note that you can use a Stack<T> instead to turn to Depth-first search algorithm. Here you have the extension method: