A library for working with phylogenetic and population genetic data.
v0.32.0
BaseWindowStream< InputStreamIterator, Data, WindowType >::Iterator Class Referencefinal

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

Detailed Description

template<class InputStreamIterator, class Data = typename InputStreamIterator::value_type, class WindowType = typename ::genesis::population::Window<Data>>
class genesis::population::BaseWindowStream< InputStreamIterator, Data, WindowType >::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 186 of file base_window_stream.hpp.

Public Member Functions

 Iterator ()=default
 
 Iterator (Iterator &&other)
 
 Iterator (Iterator const &)=delete
 
 ~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= (Iterator &&other)
 
Iteratoroperator= (Iterator const &)=delete
 
bool operator== (self_type const &other) const
 Compare two iterators for equality. More...
 

Public Types

using const_reference = value_type const &
 
using InputType = typename InputStreamType::value_type
 
using iterator_category = std::input_iterator_tag
 
using pointer = value_type *
 
using reference = value_type &
 
using self_type = typename BaseWindowStream< InputStreamType, DataType, WindowType >::Iterator
 
using value_type = WindowType
 

Public Attributes

friend BaseWindowStream
 

Protected Member Functions

 Iterator (BaseWindowStream const *parent, std::unique_ptr< BaseIterator > base_iterator)
 

Constructor & Destructor Documentation

◆ Iterator() [1/4]

Iterator ( BaseWindowStream const *  parent,
std::unique_ptr< BaseIterator base_iterator 
)
inlineprotected

Definition at line 211 of file base_window_stream.hpp.

◆ Iterator() [2/4]

Iterator ( )
default

◆ ~Iterator()

~Iterator ( )
default

◆ Iterator() [3/4]

Iterator ( Iterator const &  )
delete

◆ Iterator() [4/4]

Iterator ( Iterator &&  other)
inline

Definition at line 244 of file base_window_stream.hpp.

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 286 of file base_window_stream.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 302 of file base_window_stream.hpp.

◆ operator!=()

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

Definition at line 394 of file base_window_stream.hpp.

◆ operator*() [1/2]

value_type& operator* ( )
inline

Definition at line 318 of file base_window_stream.hpp.

◆ operator*() [2/2]

const value_type& operator* ( ) const
inline

Definition at line 312 of file base_window_stream.hpp.

◆ operator++()

self_type& operator++ ( )
inline

Definition at line 340 of file base_window_stream.hpp.

◆ operator->() [1/2]

value_type* operator-> ( )
inline

Definition at line 330 of file base_window_stream.hpp.

◆ operator->() [2/2]

const value_type* operator-> ( ) const
inline

Definition at line 324 of file base_window_stream.hpp.

◆ operator=() [1/2]

Iterator& operator= ( Iterator &&  other)
inline

Definition at line 258 of file base_window_stream.hpp.

◆ operator=() [2/2]

Iterator& operator= ( Iterator const &  )
delete

◆ 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 BaseWindowStream they were created. Two past-the-end iterators compare equal.

Definition at line 384 of file base_window_stream.hpp.

Member Typedef Documentation

◆ const_reference

using const_reference = value_type const&

Definition at line 203 of file base_window_stream.hpp.

◆ InputType

using InputType = typename InputStreamType::value_type

Definition at line 197 of file base_window_stream.hpp.

◆ iterator_category

using iterator_category = std::input_iterator_tag

Definition at line 199 of file base_window_stream.hpp.

◆ pointer

using pointer = value_type*

Definition at line 201 of file base_window_stream.hpp.

◆ reference

Definition at line 202 of file base_window_stream.hpp.

◆ self_type

using self_type = typename BaseWindowStream< InputStreamType, DataType, WindowType >::Iterator

Definition at line 196 of file base_window_stream.hpp.

◆ value_type

using value_type = WindowType

Definition at line 200 of file base_window_stream.hpp.

Member Data Documentation

◆ BaseWindowStream

Definition at line 270 of file base_window_stream.hpp.


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