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::SharedFieldIterator< VALUE_TYPE > Class Template Reference

iterator for SharedField objects. More...

#include <shared_field_iterator.h>

Inheritance diagram for gamgee::SharedFieldIterator< VALUE_TYPE >:

Public Member Functions

 SharedFieldIterator ()
 default constructor of an empty iterator More...
 
 SharedFieldIterator (const std::shared_ptr< bcf1_t > &body, uint8_t *data_ptr, uint8_t *end_ptr, const uint8_t bytes_per_value, const utils::VariantFieldType &type)
 Constructor with bcf1_t structure and start and end pointers of the vector/array. More...
 
 SharedFieldIterator (const std::shared_ptr< bcf1_t > &body, uint8_t *data_ptr, const uint8_t bytes_per_value, const utils::VariantFieldType &type)
 Constructor with bcf1_t structure and start pointer of the vector/array. More...
 
 SharedFieldIterator (const SharedFieldIterator &other)=default
 standard copy constructor creates a new iterator pointing to the same underlying data More...
 
 SharedFieldIterator (SharedFieldIterator &&other)=default
 standard move constructor More...
 
SharedFieldIteratoroperator= (const SharedFieldIterator &other)=default
 standard copy assignment operator creates a new iterator pointing to the same underlying data More...
 
SharedFieldIteratoroperator= (SharedFieldIterator &&other)=default
 two iterators are equal if they are in exactly the same state (pointing at the same location in memory More...
 
bool operator== (const SharedFieldIterator &other)
 
bool operator!= (const SharedFieldIterator &other)
 the negation of SharedFieldIterator::operator==() More...
 
bool operator< (const SharedFieldIterator &other)
 an operator is greater/less than another iterator if it is pointing to a previous element in the SharedField object. The order is determined by the Variant record. More...
 
bool operator> (const SharedFieldIterator &other)
 not smaller than other neither equal to other More...
 
bool operator<= (const SharedFieldIterator &other)
 not greater than other More...
 
bool operator>= (const SharedFieldIterator &other)
 not smaller than other More...
 
VALUE_TYPE operator* () const noexcept
 
VALUE_TYPE read_and_cache_current_pointee () noexcept
 
SharedFieldIteratoroperator+= (const int n)
 
SharedFieldIteratoroperator-= (const int n)
 
SharedFieldIteratoroperator++ () noexcept
 advances to the next value More...
 
SharedFieldIterator operator++ (int) noexcept
 Postfix increment. Advances to the next sample. More...
 
SharedFieldIteratoroperator-- ()
 advances to the previous value More...
 
SharedFieldIterator operator-- (int) noexcept
 Postfix decrement. Move back to the previous sample. More...
 
int32_t operator- (const SharedFieldIterator &first) const
 difference between two iterators as an integer. More...
 
VALUE_TYPE operator[] (const uint32_t index) const
 random access to the value of a given index for reading or writing More...
 

Detailed Description

template<class VALUE_TYPE>
class gamgee::SharedFieldIterator< VALUE_TYPE >

iterator for SharedField objects.

This iterator will walk through all the values for a given SharedField object. For example if you want to iterate over all the AN 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 VALUE_TYPE >
gamgee::SharedFieldIterator< VALUE_TYPE >::SharedFieldIterator ( )
inline

default constructor of an empty iterator

Note
useful for creating begin/end iterators over empty objects that match
template<class VALUE_TYPE >
gamgee::SharedFieldIterator< VALUE_TYPE >::SharedFieldIterator ( const std::shared_ptr< bcf1_t > &  body,
uint8_t *  data_ptr,
uint8_t *  end_ptr,
const uint8_t  bytes_per_value,
const utils::VariantFieldType type 
)
inlineexplicit

Constructor with bcf1_t structure and start and end pointers of the vector/array.

Parameters
bodya pointer to the bcf1_t data structure to be held as a shared pointer
data_ptrthe byte array containing the value(s) for this shared field
end_ptrthe end pointer value of the data array
bytes_per_valuenumber of bytes in each value
typethe encoding of the value
Note
this constructor is probably only used by SharedField::begin() and SharedField::end()
template<class VALUE_TYPE >
gamgee::SharedFieldIterator< VALUE_TYPE >::SharedFieldIterator ( const std::shared_ptr< bcf1_t > &  body,
uint8_t *  data_ptr,
const uint8_t  bytes_per_value,
const utils::VariantFieldType type 
)
inlineexplicit

Constructor with bcf1_t structure and start pointer of the vector/array.

Parameters
bodya pointer to the bcf1_t data structure to be held as a shared pointer
data_ptrthe byte array containing the value(s) for this shared field
bytes_per_valuenumber of bytes in each value
typethe encoding of the value
Note
this constructor is probably only used by SharedField::begin() and SharedField::end()
template<class VALUE_TYPE >
gamgee::SharedFieldIterator< VALUE_TYPE >::SharedFieldIterator ( const SharedFieldIterator< VALUE_TYPE > &  other)
default

standard copy constructor creates a new iterator pointing to the same underlying data

template<class VALUE_TYPE >
gamgee::SharedFieldIterator< VALUE_TYPE >::SharedFieldIterator ( SharedFieldIterator< VALUE_TYPE > &&  other)
default

standard move constructor

Member Function Documentation

template<class VALUE_TYPE >
bool gamgee::SharedFieldIterator< VALUE_TYPE >::operator!= ( const SharedFieldIterator< VALUE_TYPE > &  other)
inline
template<class VALUE_TYPE >
VALUE_TYPE gamgee::SharedFieldIterator< VALUE_TYPE >::operator* ( ) const
inlinenoexcept
template<class VALUE_TYPE >
SharedFieldIterator& gamgee::SharedFieldIterator< VALUE_TYPE >::operator++ ( )
inlinenoexcept

advances to the next value

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 of operator* with end(). This is the STL way.
Returns
updated iterator
template<class VALUE_TYPE >
SharedFieldIterator gamgee::SharedFieldIterator< VALUE_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 current iterator before the increment
template<class VALUE_TYPE >
SharedFieldIterator& gamgee::SharedFieldIterator< VALUE_TYPE >::operator+= ( const int  n)
inline

advance n values

template<class VALUE_TYPE >
int32_t gamgee::SharedFieldIterator< VALUE_TYPE >::operator- ( const SharedFieldIterator< VALUE_TYPE > &  first) const
inline

difference between two iterators as an integer.

Parameters
firstis the iterator the position of which is to be subtracted from the position of the current iterator.
Returns
the number of values steps between first and last.
template<class VALUE_TYPE >
SharedFieldIterator& gamgee::SharedFieldIterator< VALUE_TYPE >::operator-- ( )
inline

advances to the previous value

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 of operator* with end(). This is the STL way.
Returns
updated iterator
template<class VALUE_TYPE >
SharedFieldIterator gamgee::SharedFieldIterator< VALUE_TYPE >::operator-- ( int  )
inlinenoexcept

Postfix decrement. Move back 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 end by comparing the result with end(). This is the STL way.
Returns
copy of current iterator before the decrement
template<class VALUE_TYPE >
SharedFieldIterator& gamgee::SharedFieldIterator< VALUE_TYPE >::operator-= ( const int  n)
inline

moves back n values

template<class VALUE_TYPE >
bool gamgee::SharedFieldIterator< VALUE_TYPE >::operator< ( const SharedFieldIterator< VALUE_TYPE > &  other)
inline

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

template<class VALUE_TYPE >
bool gamgee::SharedFieldIterator< VALUE_TYPE >::operator<= ( const SharedFieldIterator< VALUE_TYPE > &  other)
inline

not greater than other

template<class VALUE_TYPE >
SharedFieldIterator& gamgee::SharedFieldIterator< VALUE_TYPE >::operator= ( const SharedFieldIterator< VALUE_TYPE > &  other)
default

standard copy assignment operator creates a new iterator pointing to the same underlying data

template<class VALUE_TYPE >
SharedFieldIterator& gamgee::SharedFieldIterator< VALUE_TYPE >::operator= ( SharedFieldIterator< VALUE_TYPE > &&  other)
default

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

standard move assignment operator

template<class VALUE_TYPE >
bool gamgee::SharedFieldIterator< VALUE_TYPE >::operator== ( const SharedFieldIterator< VALUE_TYPE > &  other)
inline
template<class VALUE_TYPE >
bool gamgee::SharedFieldIterator< VALUE_TYPE >::operator> ( const SharedFieldIterator< VALUE_TYPE > &  other)
inline

not smaller than other neither equal to other

template<class VALUE_TYPE >
bool gamgee::SharedFieldIterator< VALUE_TYPE >::operator>= ( const SharedFieldIterator< VALUE_TYPE > &  other)
inline

not smaller than other

template<class VALUE_TYPE >
VALUE_TYPE gamgee::SharedFieldIterator< VALUE_TYPE >::operator[] ( const uint32_t  index) const
inline

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

Parameters
indexmust be between 0 and the number of indices for this record but no boundary check is done in this implementation
Note
implementation guarantees this operation to be O(1)
Warning
does not check for bounds exception, you should verify whether or not you've reached the end by comparing the result of operator* with end(). This is the STL way (for iterators).
Returns
the value in it's native type
template<class VALUE_TYPE >
VALUE_TYPE gamgee::SharedFieldIterator< VALUE_TYPE >::read_and_cache_current_pointee ( )
inlinenoexcept

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