A library for working with phylogenetic and population genetic data.
v0.27.0
BaseWindowIterator< ForwardIterator, DataType >::Iterator Class Reference

#include <genesis/population/window/base_window_iterator.hpp>

Detailed Description

template<class ForwardIterator, class DataType = typename ForwardIterator::value_type>
class genesis::population::BaseWindowIterator< ForwardIterator, DataType >::Iterator

Internal public iterator that produces Windows.

This is the iterator that is exposed to the user when calling begin() and end() on the main class. Using this interface ensures that all types of window iterators (sliding window, regions, etc) expose the same type of iterator (at least for the same template parameters), making it easier to re-use code across different types of window iterators.

We internally use a PIMPL-like setup to abstract away from this and allow the actual iterator implementations to run their own code. However, we here don't use PIMPL to hide our implementation, but rather to simply abstract from it, so that the public interface stays stable. See BaseIterator below for the class that needs to be derived from to implement the actual window iteration code.

Definition at line 173 of file base_window_iterator.hpp.

Public Member Functions

 Iterator (self_type &&)=default
 
 Iterator (self_type const &)=default
 
 ~Iterator ()=default
 
bool is_first_window () const
 Return whether the current iteration is the first of the current chromosome. More...
 
bool is_last_window () const
 Return whether the current iteration is the last of the current chromosome. More...
 
bool operator!= (self_type const &other) const
 
value_typeoperator* ()
 
const value_typeoperator* () const
 
self_typeoperator++ ()
 
value_typeoperator-> ()
 
const value_typeoperator-> () const
 
Iteratoroperator= (self_type &&)=default
 
Iteratoroperator= (self_type const &)=default
 
bool operator== (self_type const &other) const
 Compare two iterators for equality. More...
 

Public Types

using const_reference = value_type const &
 
using Entry = typename Window::Entry
 
using InputType = typename ForwardIterator::value_type
 
using iterator_category = std::input_iterator_tag
 
using pointer = value_type *
 
using reference = value_type &
 
using self_type = BaseWindowIterator< ForwardIterator, DataType >::Iterator
 
using value_type = Window
 
using Window = ::genesis::population::Window< DataType >
 

Public Attributes

friend BaseWindowIterator
 

Protected Member Functions

 Iterator ()=delete
 
 Iterator (std::unique_ptr< BaseIterator > base_iterator)
 

Constructor & Destructor Documentation

◆ Iterator() [1/4]

Iterator ( )
protecteddelete

◆ Iterator() [2/4]

Iterator ( std::unique_ptr< BaseIterator base_iterator)
inlineprotected

Definition at line 197 of file base_window_iterator.hpp.

◆ ~Iterator()

~Iterator ( )
default

◆ Iterator() [3/4]

Iterator ( self_type const &  )
default

◆ Iterator() [4/4]

Iterator ( self_type &&  )
default

Member Function Documentation

◆ is_first_window()

bool is_first_window ( ) const
inline

Return whether the current iteration is the first of the current chromosome.

When iterating over (e.g.) a VCF file with multiple chromosomes, this function is useful to run some initialization per chromosome in the user code, such as preparing some output.

See is_last_window() for the respective end-of-chromosome indicator, that can be used to wrap up after a chromosome, such as writing the output that was producing during the iterator.

Definition at line 227 of file base_window_iterator.hpp.

◆ is_last_window()

bool is_last_window ( ) const
inline

Return whether the current iteration is the last of the current chromosome.

When iterating over (e.g.) a VCF file with multiple chromosomes, this function is useful to wrap up after a chromosome in the user code, such as writing the output that was producing during the iterator.

See is_first_window() for the respective beginning-of-chromosome indicator, that can be used to run some initialization per chromosome, such as preparing some output.

Definition at line 243 of file base_window_iterator.hpp.

◆ operator!=()

bool operator!= ( self_type const &  other) const
inline

Definition at line 314 of file base_window_iterator.hpp.

◆ operator*() [1/2]

value_type& operator* ( )
inline

Definition at line 259 of file base_window_iterator.hpp.

◆ operator*() [2/2]

const value_type& operator* ( ) const
inline

Definition at line 253 of file base_window_iterator.hpp.

◆ operator++()

self_type& operator++ ( )
inline

Definition at line 281 of file base_window_iterator.hpp.

◆ operator->() [1/2]

value_type* operator-> ( )
inline

Definition at line 271 of file base_window_iterator.hpp.

◆ operator->() [2/2]

const value_type* operator-> ( ) const
inline

Definition at line 265 of file base_window_iterator.hpp.

◆ operator=() [1/2]

Iterator& operator= ( self_type &&  )
default

◆ operator=() [2/2]

Iterator& operator= ( self_type const &  )
default

◆ operator==()

bool operator== ( self_type const &  other) const
inline

Compare two iterators for equality.

Any two iterators that are copies of each other or started from the same parent will compare equal, as long as neither of them is past-the-end. A valid (not past-the-end) iterator and an end() iterator will not compare equal, no matter from which BaseWindowIterator they were created. Two past-the-end iterators compare equal.

Definition at line 304 of file base_window_iterator.hpp.

Member Typedef Documentation

◆ const_reference

using const_reference = value_type const&

Definition at line 191 of file base_window_iterator.hpp.

◆ Entry

using Entry = typename Window::Entry

Definition at line 184 of file base_window_iterator.hpp.

◆ InputType

using InputType = typename ForwardIterator::value_type

Definition at line 185 of file base_window_iterator.hpp.

◆ iterator_category

using iterator_category = std::input_iterator_tag

Definition at line 187 of file base_window_iterator.hpp.

◆ pointer

using pointer = value_type*

Definition at line 189 of file base_window_iterator.hpp.

◆ reference

Definition at line 190 of file base_window_iterator.hpp.

◆ self_type

using self_type = BaseWindowIterator<ForwardIterator, DataType>::Iterator

Definition at line 181 of file base_window_iterator.hpp.

◆ value_type

using value_type = Window

Definition at line 188 of file base_window_iterator.hpp.

◆ Window

using Window = ::genesis::population::Window<DataType>

Definition at line 183 of file base_window_iterator.hpp.

Member Data Documentation

◆ BaseWindowIterator

Definition at line 211 of file base_window_iterator.hpp.


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