|
A library for working with phylogenetic and population genetic data.
v0.27.0
|
|
Go to the documentation of this file. 1 #ifndef GENESIS_POPULATION_WINDOW_BASE_WINDOW_ITERATOR_H_
2 #define GENESIS_POPULATION_WINDOW_BASE_WINDOW_ITERATOR_H_
43 #include <type_traits>
47 namespace population {
105 template<
class ForwardIterator,
class DataType =
typename ForwardIterator::value_type>
197 Iterator( std::unique_ptr<BaseIterator> base_iterator )
198 : pimpl_( std::move( base_iterator ))
230 return pimpl_->is_first_window_;
246 return pimpl_->is_last_window_;
256 return pimpl_->get_current_window_();
262 return pimpl_->get_current_window_();
268 return &( pimpl_->get_current_window_() );
274 return &( pimpl_->get_current_window_() );
284 pimpl_->increment_();
307 assert( other.pimpl_ );
311 return pimpl_->get_parent_() == other.pimpl_->get_parent_();
316 return !(*
this == other);
325 std::unique_ptr<BaseIterator> pimpl_;
412 throw std::runtime_error(
413 "Need to set BaseWindowIterator::entry_input_function "
414 "before iterating over Windows with a Window Iterator."
418 throw std::runtime_error(
419 "Need to set BaseWindowIterator::chromosome_function "
420 "before iterating over Windows with a Window Iterator."
424 throw std::runtime_error(
425 "Need to set BaseWindowIterator::position_function "
426 "before iterating over Windows with a Window Iterator."
482 ForwardIterator
begin, ForwardIterator
end
528 ForwardIterator begin_;
529 ForwardIterator end_;
536 #endif // include guard
BaseWindowIterator(ForwardIterator begin, ForwardIterator end)
bool operator!=(self_type const &other) const
friend BaseWindowIterator
virtual value_type & get_current_window_() const =0
Get the current window that the iterator shall return when dereferenced.
::genesis::population::Window< DataType > Window
virtual void increment_()=0
Advance in the iteration. This function is called from operator++.
Base iterator class for Windows over the chromosomes of a genome.
const value_type & operator*() const
Iterator & operator=(self_type const &)=default
BaseWindowIterator & operator=(BaseWindowIterator const &)=default
BaseIterator(BaseWindowIterator const *parent)
Construct the base class, which does initialization checks on its member variables to ensure that the...
Window over the chromosomes of a genome.
Internal PIMPL-like implementation of the iterator that produces Windows.
virtual std::unique_ptr< BaseIterator > get_begin_iterator_()=0
value_type const & const_reference
typename ForwardIterator::value_type InputType
Iterator(std::unique_ptr< BaseIterator > base_iterator)
bool is_first_window() const
Return whether the current iteration is the first of the current chromosome.
Provides some valuable additions to STD.
value_type const & const_reference
value_type * operator->()
::genesis::population::Window< DataType > Window
std::input_iterator_tag iterator_category
std::function< DataType(InputType const &)> entry_input_function
Functor to convert from the underlying input iterator that provides the data to fill the windows to t...
std::function< std::string(InputType const &)> chromosome_function
Functor that yields the current chromosome, given the input iterator data.
Internal public iterator that produces Windows.
::genesis::population::Window< DataType > Window
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
typename Window::Entry Entry
std::function< size_t(InputType const &)> position_function
Functor that yields the current position on the chromosome, given the input iterator data.
Data that is stored per entry that was enqueued in a window.
const value_type * operator->() const
friend BaseWindowIterator
value_type const & const_reference
void init_(BaseWindowIterator const *parent)
Initialize the base iterator class and check that it is set up correctly.
typename Window::Entry Entry
std::input_iterator_tag iterator_category
virtual std::unique_ptr< BaseIterator > get_end_iterator_()=0
typename ForwardIterator::value_type InputType
BaseIterator & operator=(self_type const &)=default
typename Window::Entry Entry
typename ForwardIterator::value_type InputType
std::input_iterator_tag iterator_category
virtual BaseWindowIterator const * get_parent_() const =0
Get a pointer to the base class parent.
bool is_last_window() const
Return whether the current iteration is the last of the current chromosome.
bool operator==(self_type const &other) const
Compare two iterators for equality.
~BaseWindowIterator()=default