|
A library for working with phylogenetic and population genetic data.
v0.32.0
|
|
Go to the documentation of this file. 1 #ifndef GENESIS_UTILS_CONTAINERS_INTERVAL_TREE_ITERATOR_H_
2 #define GENESIS_UTILS_CONTAINERS_INTERVAL_TREE_ITERATOR_H_
47 #include <type_traits>
70 template<
typename NodeType,
bool is_const = true >
71 class IntervalTreeIterator
72 :
public std::forward_iterator_tag
91 using node_ptr_t =
typename std::conditional< is_const, node_type const*, node_type* >::type;
92 using owner_type =
typename std::conditional< is_const, tree_type const*, tree_type* >::type;
111 IntervalTreeIterator( IntervalTreeIterator
const& ) =
default;
112 IntervalTreeIterator( IntervalTreeIterator&& ) =
default;
114 IntervalTreeIterator&
operator= ( IntervalTreeIterator
const& ) =
default;
115 IntervalTreeIterator&
operator= ( IntervalTreeIterator&& ) =
default;
125 return node_ != other.node_;
130 return node_ == other.node_;
136 node_ = owner_->root_;
140 while( node_->left_ ){
141 node_ = node_->left_;
145 if( node_->right_ ) {
146 node_ = node_->right_;
147 while( node_->left_ ){
148 node_ = node_->left_;
151 auto*
parent = node_->parent_;
172 return node_->interval();
174 throw std::out_of_range(
"Dereferencing IntervalTreeIterator out of bounds.");
195 return {node_->parent_, owner_};
197 throw std::out_of_range(
"interval_tree_iterator out of bounds");
208 return {node_->left_, owner_};
210 throw std::out_of_range(
"interval_tree_iterator out of bounds");
221 return {node_->right_, owner_};
223 throw std::out_of_range(
"interval_tree_iterator out of bounds");
239 return node_->color();
244 return node_->interval();
261 #endif // include guard
typename NodeType::interval_type interval_type
value_type const * operator->() const
numerical_type max() const
Return the max property of the node.
self_type parent() const
Return an iterator to the parent of this node.
typename NodeType::interval_kind interval_kind
~IntervalTreeIterator()=default
Iterate the Intervals stored in an IntervalTree.
typename std::conditional< is_const, tree_type const *, tree_type * >::type owner_type
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
typename NodeType::data_type data_type
RedBackColor
Definition for Red-Black Tree coloring.
self_type operator++(int)
bool operator!=(IntervalTreeIterator const &other) const
typename NodeType::numerical_type numerical_type
interval_type const & interval() const
self_type right() const
Continue down the right side of this node.
bool operator==(IntervalTreeIterator const &other) const
IntervalTreeIterator & operator=(IntervalTreeIterator const &)=default
self_type left() const
Continue down the left side of this node.
Interval tree that enables storing and querying intervals, each containing some data.
interval_type const & operator*() const
RedBackColor color() const
Return the color of the node.
typename std::conditional< is_const, node_type const *, node_type * >::type node_ptr_t