1 #ifndef GENESIS_TAXONOMY_ITERATOR_LEVELORDER_H_ 2 #define GENESIS_TAXONOMY_ITERATOR_LEVELORDER_H_ 60 std::function<
void(
Taxon& )> fn,
61 bool include_inner_taxa =
true 63 std::queue< Taxon* > taxa_queue;
64 for(
auto& t : tax ) {
65 taxa_queue.push( &t );
68 while( ! taxa_queue.empty() ) {
69 auto& cur = *taxa_queue.front();
71 if( include_inner_taxa || cur.size() == 0 ) {
75 for(
auto& t : cur ) {
76 taxa_queue.push( &t );
94 std::function<
void(
Taxon const& )> fn,
95 bool include_inner_taxa =
true 97 std::queue< Taxon const* > taxa_queue;
98 for(
auto& t : tax ) {
99 taxa_queue.push( &t );
102 while( ! taxa_queue.empty() ) {
103 auto const& cur = *taxa_queue.front();
105 if( include_inner_taxa || cur.size() == 0 ) {
109 for(
auto const& t : cur ) {
110 taxa_queue.push( &t );
119 #endif // include guard void levelorder_for_each(Taxonomy &tax, std::function< void(Taxon &)> fn, bool include_inner_taxa=true)
Apply a function to all taxa of the Taxonomy, traversing it in levelorder.
Container namespace for all symbols of genesis in order to keep them separate when used as a library...
Store a Taxonomy, i.e., a nested hierarchy of Taxa.
Store a Taxon, i.e., an element in a Taxonomy, with its name, rank, ID and sub-taxa.