Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
lazy_tree_traversal_example.cc File Reference

Lazy binary tree traversal with coroutines (tpl_binNodeGenerators.H). More...

#include <iostream>
#include <vector>
#include <print_rule.H>
#include <tpl_binNode.H>
#include <tpl_binNodeGenerators.H>
#include <tpl_binNodeUtils.H>
Include dependency graph for lazy_tree_traversal_example.cc:

Go to the source code of this file.

Functions

int main ()
 

Detailed Description

Lazy binary tree traversal with coroutines (tpl_binNodeGenerators.H).

Overview

for_each_in_order/for_each_preorder/for_each_postorder (tpl_binNodeUtils.H) visit a binary tree with a void-returning callback, so those helpers always consume the whole traversal. Aleph also has eager iterator-based helpers such as infix_traverse() and prefix_traverse() whose bool callback can stop early.

lazy_in_order/lazy_pre_order/lazy_post_order (tpl_binNodeGenerators.H) traverse the exact same way, but as an Aleph::Generator<Node *> driven by a range-for. A plain break stops the traversal immediately, with no callback contract, and the result can be composed with other Generator-based code.

Author
Leandro Rabindranath Leon

Definition in file lazy_tree_traversal_example.cc.

Function Documentation

◆ main()

int main ( void  )