Gamgee
You miserable little maggot. I'll stove your head in!
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | List of all members
gamgee::IndividualFieldIterator< TYPE > Class Template Reference

iterator for VariantField objects. More...

#include <individual_field_iterator.h>

Inheritance diagram for gamgee::IndividualFieldIterator< TYPE >:

Public Member Functions

 IndividualFieldIterator (const std::shared_ptr< bcf1_t > &body, bcf_fmt_t *format_ptr, bool end_iterator=false)
 simple constructor used by VariantField to create an iterator More...
 
 IndividualFieldIterator (const IndividualFieldIterator &other)
 copy constructor is only meant for internal STL functions use. It makes a shallow copy of the underlying object which is sufficient for an iterator, but not exactly what a user would expect (user should expect copy constructors to make deep copies). But a deep copied iterator makes no sense. More...
 
 IndividualFieldIterator (IndividualFieldIterator &&other) noexcept
 safely moves the data from one VariantField to a new one without making any copies More...
 
IndividualFieldIteratoroperator= (const IndividualFieldIterator &other)
 copy constructor is only meant for internal STL functions use. It makes a shallow copy of the underlying object which is sufficient for an iterator, but not exactly what a user would expect (user should expect copy constructors to make deep copies). But a deep copied iterator makes no sense. More...
 
IndividualFieldIteratoroperator= (IndividualFieldIterator &&other) noexcept
 safely moves the data from one VariantField to a new one without making any copies More...
 
IndividualFieldIteratoroperator+= (const int n) noexcept
 simple compound assignment operation for random advances (back/forward) to the iterator More...
 
IndividualFieldIteratoroperator-= (const int n) noexcept
 simple compound assignment operation for random advances (back/forward) to the iterator More...
 
bool operator== (const IndividualFieldIterator &other)
 two iterators are equal if they are in exactly the same state (pointing at the same location in memory More...
 
bool operator!= (const IndividualFieldIterator &other)
 the oposite check of IndividualFieldIterator::operator==() More...
 
bool operator< (const IndividualFieldIterator &other)
 an operator is greater/less than another iterator if it is pointing to a previous element (sample) in the VariantField object. The order is determined by the Variant record. More...
 
bool operator> (const IndividualFieldIterator &other)
 an operator is greater/less than another iterator if it is pointing to a previous element (sample) in the VariantField object. The order is determined by the Variant record. More...
 
bool operator<= (const IndividualFieldIterator &other)
 an operator is greater/less than another iterator if it is pointing to a previous element (sample) in the VariantField object. The order is determined by the Variant record. More...
 
bool operator>= (const IndividualFieldIterator &other)
 an operator is greater/less than another iterator if it is pointing to a previous element (sample) in the VariantField object. The order is determined by the Variant record. More...
 
TYPE operator* () const noexcept
 direct access to the value of the current sample More...
 
IndividualFieldIteratoroperator++ () noexcept
 Prefix increment. Advances to the next sample. More...
 
IndividualFieldIterator operator++ (int) noexcept
 Postfix increment. Advances to the next sample. More...
 
IndividualFieldIteratoroperator-- () noexcept
 Prefix increment. Reverses to the previous sample. More...
 
IndividualFieldIterator operator-- (int) noexcept
 Postfix decrement. Reverses to the previous sample. More...
 
TYPE operator[] (const uint32_t sample) const
 random access to the value of a given sample for reading or writing More...
 
int32_t operator- (const IndividualFieldIterator< TYPE > &first) const
 Difference between two iterators as an integer. More...
 

Detailed Description

template<class TYPE>
class gamgee::IndividualFieldIterator< TYPE >

iterator for VariantField objects.

This iterator will walk through all the samples in a Variant record for a given VariantField object. For example if you want to iterate over all the GQ values of a Variant record you would do so through this iterator.

Note
implements a random access iterator which gives you full performance on STL algorithms that use iterators (mostly every one)
this iterator never makes any copies of the underlying memory. It is implemented with pointer acrobatics behind the scenes for maximum performance while maintaining a friendly interface.

Constructor & Destructor Documentation

template<class TYPE>
gamgee::IndividualFieldIterator< TYPE >::IndividualFieldIterator ( const std::shared_ptr< bcf1_t > &  body,
bcf_fmt_t format_ptr,
bool  end_iterator = false 
)
inline

simple constructor used by VariantField to create an iterator

Parameters
bodythe Variant record used to access the data (shared ownership guarantees availability until iterator goes out of scope)
format_ptrpointer to the raw byte array in body where all the values for this format field is encoded
end_iteratorwhether or not this is being called by the VariantField::end() function.
Note
this constructor serves only the VariantField::begin() and VariantField::end() functions.
template<class TYPE>
gamgee::IndividualFieldIterator< TYPE >::IndividualFieldIterator ( const IndividualFieldIterator< TYPE > &  other)
inline

copy constructor is only meant for internal STL functions use. It makes a shallow copy of the underlying object which is sufficient for an iterator, but not exactly what a user would expect (user should expect copy constructors to make deep copies). But a deep copied iterator makes no sense.

Warning
does not deep copy the underlying data! (but the copied iterator will be able to navigate independentely).
template<class TYPE>
gamgee::IndividualFieldIterator< TYPE >::IndividualFieldIterator ( IndividualFieldIterator< TYPE > &&  other)
inlinenoexcept

safely moves the data from one VariantField to a new one without making any copies

Parameters
otheranother VariantField object

Member Function Documentation

template<class TYPE>
bool gamgee::IndividualFieldIterator< TYPE >::operator!= ( const IndividualFieldIterator< TYPE > &  other)
inline
template<class TYPE>
TYPE gamgee::IndividualFieldIterator< TYPE >::operator* ( ) const
inlinenoexcept

direct access to the value of the current sample

Returns
the value if it is a basic type (e.g. GQ, GL), or a specific object if it is a complex type (e.g. PL, AD,...)
template<class TYPE>
IndividualFieldIterator& gamgee::IndividualFieldIterator< TYPE >::operator++ ( )
inlinenoexcept

Prefix increment. Advances to the next sample.

Note
mainly designed for iterators
Warning
does not check for bounds exception, you should verify whether or not you've reached the end by comparing the result with end(). This is the STL way.
Returns
a reference to the start of the values of the next sample
template<class TYPE>
IndividualFieldIterator gamgee::IndividualFieldIterator< TYPE >::operator++ ( int  )
inlinenoexcept

Postfix increment. Advances to the next sample.

Note
mainly designed for iterators
Warning
does not check for bounds exception, you should verify whether or not you've reached the end by comparing the result with end(). This is the STL way.
Returns
copy of the current position of the iterator (before the increment)
template<class TYPE>
IndividualFieldIterator& gamgee::IndividualFieldIterator< TYPE >::operator+= ( const int  n)
inlinenoexcept

simple compound assignment operation for random advances (back/forward) to the iterator

Parameters
nhow much to advance (negative numbers to go the other direction)
Warning
there is no boundary check in this operator
template<class TYPE>
int32_t gamgee::IndividualFieldIterator< TYPE >::operator- ( const IndividualFieldIterator< TYPE > &  first) const
inline

Difference between two iterators as an integer.

Note
Useful as a substitute for size() when only begin() and end() are available.
Returns
the number of iterator steps between [first, last) where last is the current IndividualFieldIterator.
Parameters
firstis the iterator the position of which is to be subtracted from the position of the current iterator.
template<class TYPE>
IndividualFieldIterator& gamgee::IndividualFieldIterator< TYPE >::operator-- ( )
inlinenoexcept

Prefix increment. Reverses to the previous sample.

Note
mainly designed for iterators
Warning
does not check for bounds exception, you should verify whether or not you've reached the beginning by comparing the result with begin(). This is the STL way.
Returns
a reference to the start of the values of the previous sample
template<class TYPE>
IndividualFieldIterator gamgee::IndividualFieldIterator< TYPE >::operator-- ( int  )
inlinenoexcept

Postfix decrement. Reverses to the previous sample.

Note
mainly designed for iterators
Warning
does not check for bounds exception, you should verify whether or not you've reached the beginning by comparing the result with begin(). This is the STL way.
Returns
copy of the current position of the iterator (before the decrement)
template<class TYPE>
IndividualFieldIterator& gamgee::IndividualFieldIterator< TYPE >::operator-= ( const int  n)
inlinenoexcept

simple compound assignment operation for random advances (back/forward) to the iterator

Parameters
nhow much to advance (negative numbers to go the other direction)
Warning
there is no boundary check in this operator
template<class TYPE>
bool gamgee::IndividualFieldIterator< TYPE >::operator< ( const IndividualFieldIterator< TYPE > &  other)
inline

an operator is greater/less than another iterator if it is pointing to a previous element (sample) in the VariantField object. The order is determined by the Variant record.

template<class TYPE>
bool gamgee::IndividualFieldIterator< TYPE >::operator<= ( const IndividualFieldIterator< TYPE > &  other)
inline

an operator is greater/less than another iterator if it is pointing to a previous element (sample) in the VariantField object. The order is determined by the Variant record.

template<class TYPE>
IndividualFieldIterator& gamgee::IndividualFieldIterator< TYPE >::operator= ( const IndividualFieldIterator< TYPE > &  other)
inline

copy constructor is only meant for internal STL functions use. It makes a shallow copy of the underlying object which is sufficient for an iterator, but not exactly what a user would expect (user should expect copy constructors to make deep copies). But a deep copied iterator makes no sense.

Warning
does not deep copy the underlying data! (but the copied iterator will be able to navigate independentely).
template<class TYPE>
IndividualFieldIterator& gamgee::IndividualFieldIterator< TYPE >::operator= ( IndividualFieldIterator< TYPE > &&  other)
inlinenoexcept

safely moves the data from one VariantField to a new one without making any copies

Parameters
otheranother VariantField object
template<class TYPE>
bool gamgee::IndividualFieldIterator< TYPE >::operator== ( const IndividualFieldIterator< TYPE > &  other)
inline

two iterators are equal if they are in exactly the same state (pointing at the same location in memory

template<class TYPE>
bool gamgee::IndividualFieldIterator< TYPE >::operator> ( const IndividualFieldIterator< TYPE > &  other)
inline

an operator is greater/less than another iterator if it is pointing to a previous element (sample) in the VariantField object. The order is determined by the Variant record.

template<class TYPE>
bool gamgee::IndividualFieldIterator< TYPE >::operator>= ( const IndividualFieldIterator< TYPE > &  other)
inline

an operator is greater/less than another iterator if it is pointing to a previous element (sample) in the VariantField object. The order is determined by the Variant record.

template<class TYPE>
TYPE gamgee::IndividualFieldIterator< TYPE >::operator[] ( const uint32_t  sample) const
inline

random access to the value of a given sample for reading or writing

Parameters
samplemust be between 0 and the number of samples for this record
Note
implementation guarantees this operation to be O(1)
Exceptions
std::out_of_rangeif index is out of range
Returns
the value if it is a basic type (e.g. GQ, GL), or a specific object if it is a complex type (e.g. PL, AD,...)

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