1 #ifndef GENESIS_TAXONOMY_ITERATOR_PREORDER_H_ 2 #define GENESIS_TAXONOMY_ITERATOR_PREORDER_H_ 62 std::function<
void(
Taxon& )> fn,
63 bool include_inner_taxa =
true 65 for(
auto& t : tax ) {
66 if( include_inner_taxa || t.size() == 0 ) {
86 std::function<
void(
Taxon const& )> fn,
87 bool include_inner_taxa =
true 89 for(
auto const& t : tax ) {
90 if( include_inner_taxa || t.size() == 0 ) {
102 template <
typename TaxonomyType,
typename TaxonType>
126 for(
size_t i = 0; i < taxonomy.size(); ++i ) {
127 stack_.push( &taxonomy.at( taxonomy.size() - 1 - i ));
152 auto cur_tax = stack_.top();
157 auto const cur_size = cur_tax->size();
158 for(
size_t i = 0; i < cur_size; ++i ) {
159 stack_.push( &cur_tax->at( cur_size - 1 - i ));
174 return other.stack_ == stack_;
179 return !(other == *
this);
188 return *stack_.top();
197 std::stack< TaxonType* > stack_;
204 template<
typename TaxonomyType>
214 template<
typename TaxonomyType>
227 #endif // include guard IteratorPreorder(TaxonomyType &taxonomy)
utils::Range< IteratorPreorder< Taxonomy const, Taxon const > > preorder(TaxonomyType const &taxonomy)
Container namespace for all symbols of genesis in order to keep them separate when used as a library...
bool operator==(const self_type &other) const
Store a Taxonomy, i.e., a nested hierarchy of Taxa.
void preorder_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 preorder.
IteratorPreorder & operator=(IteratorPreorder const &)=default
Store a Taxon, i.e., an element in a Taxonomy, with its name, rank, ID and sub-taxa.
~IteratorPreorder()=default
Simple wrapper for typical begin() and end() iterators, to be used in range-based for loops...
TaxonType & taxon() const
std::forward_iterator_tag iterator_category
bool operator!=(const self_type &other) const