tree_iterator

Creator: coderz1093

Last updated:

0 purchases

TODO
Add to Cart

Description:

tree iterator

Tree_Iterator #
Provides simple operations for traversing a tree.
Works with any tree structure providing that you can return the set of children for a node when requested.
FindInTree #
Searches the tree for a child that satisfies a condition.
As soon as we find a child that satisfies the condition the tree traversal stops.
/// search the tree for the 'theOne'.
var theOne = findInTree<SMCState>(virtualRoot, (node) => node.children, (node) => node.isTheOne);
copied to clipboard
traverseTree #
Traverses the entire tree calling an function on each child.
Traversal continues until the entire tree has been traversed on the call to 'processChild' returns false.
traverseTree<SMCState>(root, (node) => node.children, (node) {
print(node);

/// return false if you want to stop traversal
return true;
});

copied to clipboard
TODO: #


change algoritm to use iteration rather than recursion.


add an iterator for us in a for loop.


offer breadth first and depth first operations.


e.g.
var theOne = findInTree<SMCState>(virtualRoot, (node) => node.children, (node) => node.isTheOne, method: TreeInterator.depthFirst);
copied to clipboard
Credits #
The project contains code from:
https://github.com/mkobuolys/flutter-design-patterns
Currently this code isn't in use but the plan is to take its breadth first/depth first algorithms and implement them into this pacagek.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files:

Customer Reviews

There are no reviews.