A library for working with phylogenetic and population genetic data.
v0.32.0
IteratorPath< is_const > Class Template Reference

#include <genesis/tree/iterator/path.hpp>

Detailed Description

template<bool is_const = true>
class genesis::tree::IteratorPath< is_const >

Definition at line 60 of file path.hpp.

Public Member Functions

 IteratorPath ()
 
 IteratorPath (IteratorPath &&)=default
 
 IteratorPath (IteratorPath const &)=default
 
 IteratorPath (LinkType &start, LinkType &finish)
 
 IteratorPath (NodeType &start, NodeType &finish)
 
 ~IteratorPath ()=default
 
EdgeTypeedge () const
 
LinkTypefinish_link () const
 
NodeTypefinish_node () const
 
bool is_last_common_ancestor () const
 Return whether the current iterator position (node) is the last common ancestor of the two start and finish nodes. More...
 
bool is_lca () const
 Alias for is_last_common_ancestor(). See there for more information. More...
 
LinkTypelink () const
 
NodeTypenode () const
 
bool operator!= (const self_type &other) const
 
self_type operator* ()
 
self_type operator++ ()
 
self_type operator++ (int)
 
IteratorPathoperator= (IteratorPath &&)=default
 
IteratorPathoperator= (IteratorPath const &)=default
 
bool operator== (const self_type &other) const
 
LinkTypestart_link () const
 
NodeTypestart_node () const
 

Public Types

using EdgeType = typename std::conditional< is_const, TreeEdge const, TreeEdge >::type
 
using iterator_category = std::forward_iterator_tag
 
using LinkType = typename std::conditional< is_const, TreeLink const, TreeLink >::type
 
using NodeType = typename std::conditional< is_const, TreeNode const, TreeNode >::type
 
using self_type = IteratorPath< is_const >
 
using TreeType = typename std::conditional< is_const, Tree const, Tree >::type
 

Constructor & Destructor Documentation

◆ IteratorPath() [1/5]

IteratorPath ( )
inline

Definition at line 86 of file path.hpp.

◆ IteratorPath() [2/5]

IteratorPath ( NodeType start,
NodeType finish 
)
inline

Definition at line 93 of file path.hpp.

◆ IteratorPath() [3/5]

IteratorPath ( LinkType start,
LinkType finish 
)
inline

Definition at line 97 of file path.hpp.

◆ ~IteratorPath()

~IteratorPath ( )
default

◆ IteratorPath() [4/5]

IteratorPath ( IteratorPath< is_const > const &  )
default

◆ IteratorPath() [5/5]

IteratorPath ( IteratorPath< is_const > &&  )
default

Member Function Documentation

◆ edge()

EdgeType& edge ( ) const
inline

Definition at line 292 of file path.hpp.

◆ finish_link()

LinkType& finish_link ( ) const
inline

Definition at line 307 of file path.hpp.

◆ finish_node()

NodeType& finish_node ( ) const
inline

Definition at line 312 of file path.hpp.

◆ is_last_common_ancestor()

bool is_last_common_ancestor ( ) const
inline

Return whether the current iterator position (node) is the last common ancestor of the two start and finish nodes.

This is useful in many cases:

  • Find the LCA (obviously).
  • Check when the path is moving away from the root again.
  • Iterating edges instead of nodes.

The last bullet point may need some explanation:

The iterator visits all nodes between the start and the finish (both included). On the path between them, there is however one edge fewer than the number of visited nodes. That means, if you want to visit each edge on the path between two nodes (instead of each node), you need a way to spot this superflous edge. This function indicates the edge that needs to be skipped in this case.

Definition at line 269 of file path.hpp.

◆ is_lca()

bool is_lca ( ) const
inline

Alias for is_last_common_ancestor(). See there for more information.

Definition at line 277 of file path.hpp.

◆ link()

LinkType& link ( ) const
inline

Definition at line 282 of file path.hpp.

◆ node()

NodeType& node ( ) const
inline

Definition at line 287 of file path.hpp.

◆ operator!=()

bool operator!= ( const self_type other) const
inline

Definition at line 242 of file path.hpp.

◆ operator*()

self_type operator* ( )
inline

Definition at line 207 of file path.hpp.

◆ operator++() [1/2]

self_type operator++ ( )
inline

Definition at line 212 of file path.hpp.

◆ operator++() [2/2]

self_type operator++ ( int  )
inline

Definition at line 228 of file path.hpp.

◆ operator=() [1/2]

IteratorPath& operator= ( IteratorPath< is_const > &&  )
default

◆ operator=() [2/2]

IteratorPath& operator= ( IteratorPath< is_const > const &  )
default

◆ operator==()

bool operator== ( const self_type other) const
inline

Definition at line 235 of file path.hpp.

◆ start_link()

LinkType& start_link ( ) const
inline

Definition at line 297 of file path.hpp.

◆ start_node()

NodeType& start_node ( ) const
inline

Definition at line 302 of file path.hpp.

Member Typedef Documentation

◆ EdgeType

using EdgeType = typename std::conditional< is_const, TreeEdge const, TreeEdge >::type

Definition at line 73 of file path.hpp.

◆ iterator_category

using iterator_category = std::forward_iterator_tag

Definition at line 76 of file path.hpp.

◆ LinkType

using LinkType = typename std::conditional< is_const, TreeLink const, TreeLink >::type

Definition at line 71 of file path.hpp.

◆ NodeType

using NodeType = typename std::conditional< is_const, TreeNode const, TreeNode >::type

Definition at line 72 of file path.hpp.

◆ self_type

using self_type = IteratorPath< is_const >

Definition at line 75 of file path.hpp.

◆ TreeType

using TreeType = typename std::conditional< is_const, Tree const, Tree >::type

Definition at line 70 of file path.hpp.


The documentation for this class was generated from the following file: