|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file. 1 #ifndef GENESIS_TREE_ITERATOR_LEVELORDER_H_
2 #define GENESIS_TREE_ITERATOR_LEVELORDER_H_
41 #include <type_traits>
60 template<
bool is_const = true >
71 using TreeType =
typename std::conditional< is_const, Tree const, Tree >::type;
72 using LinkType =
typename std::conditional< is_const, TreeLink const, TreeLink >::type;
73 using NodeType =
typename std::conditional< is_const, TreeNode const, TreeNode >::type;
74 using EdgeType =
typename std::conditional< is_const, TreeEdge const, TreeEdge >::type;
108 push_back_children_( &
link, 0 );
109 stack_.push_front({ &
link.outer(), 1 });
113 : start_( &(subtree.
link()) )
114 , link_( &(subtree.
link()) )
119 push_back_children_( &(subtree.
link()), 0 );
141 if (stack_.empty()) {
145 auto const& se = stack_.front();
149 push_back_children_(link_, depth_);
164 return other.link_ == link_;
169 return !(other == *
this);
178 return link_ == start_;
193 return link_->node();
198 return link_->edge();
208 return start_->node();
224 void push_back_children_(
LinkType*
link,
int link_depth )
228 stack_.push_back({ &c->outer(), link_depth + 1 });
251 std::deque<StackElement> stack_;
258 template<
typename ElementType>
259 utils::Range< IteratorLevelorder< true >>
268 template<
typename ElementType>
281 #endif // include guard
TreeLink const & link() const
Get the TreeLink that separates the subtree from the rest of the tree.
LinkType & start_link() const
bool is_first_iteration() const
IteratorLevelorder(Subtree const &subtree)
bool operator!=(const self_type &other) const
~IteratorLevelorder()=default
utils::Range< IteratorLevelorder< true > > levelorder(ElementType const &element)
NodeType & start_node() const
IteratorLevelorder & operator=(IteratorLevelorder const &)=default
Reference to a subtree of a Tree.
IteratorLevelorder(LinkType &link)
Simple wrapper for typical begin() and end() iterators, to be used in range-based for loops.
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
typename std::conditional< is_const, TreeLink const, TreeLink >::type LinkType
typename std::conditional< is_const, TreeEdge const, TreeEdge >::type EdgeType
std::forward_iterator_tag iterator_category
IteratorLevelorder(TreeType &tree)
typename std::conditional< is_const, TreeNode const, TreeNode >::type NodeType
IteratorLevelorder(NodeType &node)
typename std::conditional< is_const, Tree const, Tree >::type TreeType