1 #ifndef gamgee__individual_field_iterator__guard
2 #define gamgee__individual_field_iterator__guard
4 #include "../utils/utils.h"
40 m_format_ptr {format_ptr},
41 m_data_ptr {end_iterator ? format_ptr->p + m_format_ptr->
size * m_body->n_sample : format_ptr->p}
53 m_body {other.m_body},
54 m_format_ptr {other.m_format_ptr},
55 m_data_ptr {other.m_data_ptr}
63 m_body {std::move(other.m_body)},
64 m_format_ptr {other.m_format_ptr},
65 m_data_ptr {other.m_data_ptr}
72 m_body = other.m_body;
73 m_format_ptr = other.m_format_ptr;
74 m_data_ptr = other.m_data_ptr;
82 m_body = std::move(other.m_body);
83 m_format_ptr = other.m_format_ptr;
84 m_data_ptr = other.m_data_ptr;
94 m_data_ptr += n * m_format_ptr->
size;
102 m_data_ptr -= n * m_format_ptr->
size;
110 return m_body == other.m_body && m_data_ptr == other.m_data_ptr;
117 return m_body != other.m_body || m_data_ptr != other.m_data_ptr;
125 return m_body == other.m_body && m_data_ptr < other.m_data_ptr;
132 return m_body == other.m_body && m_data_ptr > other.m_data_ptr;
139 return m_body == other.m_body && m_data_ptr <= other.m_data_ptr;
146 return m_body == other.m_body && m_data_ptr >= other.m_data_ptr;
154 return TYPE{m_body, m_format_ptr, m_data_ptr};
211 uint32_t curr_sample_idx = (uint32_t)(((uint64_t)(m_data_ptr - m_format_ptr->
p))/(m_format_ptr->
size));
213 return TYPE{m_body, m_format_ptr, m_data_ptr + (sample * m_format_ptr->size)};
223 return static_cast<int32_t
>(m_data_ptr - first.m_data_ptr)/m_format_ptr->
size;
227 std::shared_ptr<bcf1_t> m_body;
235 #endif // gamgee__individual_field_iterator__guard
bool operator<(const IndividualFieldIterator &other)
an operator is greater/less than another iterator if it is pointing to a previous element (sample) in...
Definition: individual_field_iterator.h:124
IndividualFieldIterator(IndividualFieldIterator &&other) noexcept
safely moves the data from one VariantField to a new one without making any copies ...
Definition: individual_field_iterator.h:62
uint8_t * p
Definition: vcf.h:139
void check_max_boundary(const uint32_t index, const uint32_t size, const std::string &prefix_msg)
checks that an index is greater than or equal to size
Definition: utils.h:63
IndividualFieldIterator & operator--() noexcept
Prefix increment. Reverses to the previous sample.
Definition: individual_field_iterator.h:186
bool operator>(const IndividualFieldIterator &other)
an operator is greater/less than another iterator if it is pointing to a previous element (sample) in...
Definition: individual_field_iterator.h:131
bool operator!=(const IndividualFieldIterator &other)
the oposite check of IndividualFieldIterator::operator==()
Definition: individual_field_iterator.h:116
TYPE operator*() const noexcept
direct access to the value of the current sample
Definition: individual_field_iterator.h:153
TYPE operator[](const uint32_t sample) const
random access to the value of a given sample for reading or writing
Definition: individual_field_iterator.h:210
bool operator==(const IndividualFieldIterator &other)
two iterators are equal if they are in exactly the same state (pointing at the same location in memor...
Definition: individual_field_iterator.h:109
bool operator<=(const IndividualFieldIterator &other)
an operator is greater/less than another iterator if it is pointing to a previous element (sample) in...
Definition: individual_field_iterator.h:138
IndividualFieldIterator & operator=(IndividualFieldIterator &&other) noexcept
safely moves the data from one VariantField to a new one without making any copies ...
Definition: individual_field_iterator.h:81
IndividualFieldIterator & operator+=(const int n) noexcept
simple compound assignment operation for random advances (back/forward) to the iterator ...
Definition: individual_field_iterator.h:93
bool operator>=(const IndividualFieldIterator &other)
an operator is greater/less than another iterator if it is pointing to a previous element (sample) in...
Definition: individual_field_iterator.h:145
int32_t operator-(const IndividualFieldIterator< TYPE > &first) const
Difference between two iterators as an integer.
Definition: individual_field_iterator.h:222
IndividualFieldIterator & operator=(const IndividualFieldIterator &other)
copy constructor is only meant for internal STL functions use. It makes a shallow copy of the underly...
Definition: individual_field_iterator.h:71
IndividualFieldIterator & operator++() noexcept
Prefix increment. Advances to the next sample.
Definition: individual_field_iterator.h:163
IndividualFieldIterator(const IndividualFieldIterator &other)
copy constructor is only meant for internal STL functions use. It makes a shallow copy of the underly...
Definition: individual_field_iterator.h:52
IndividualFieldIterator & operator-=(const int n) noexcept
simple compound assignment operation for random advances (back/forward) to the iterator ...
Definition: individual_field_iterator.h:101
void iterator(const char *fname)
Definition: test-vcf-api.c:248
IndividualFieldIterator operator--(int) noexcept
Postfix decrement. Reverses to the previous sample.
Definition: individual_field_iterator.h:197
IndividualFieldIterator operator++(int) noexcept
Postfix increment. Advances to the next sample.
Definition: individual_field_iterator.h:174
Definition: exceptions.h:9
iterator for VariantField objects.
Definition: individual_field_iterator.h:28
int size
Definition: vcf.h:138
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
Definition: individual_field_iterator.h:38