Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ska::cheetah::data::DataSequence2DFastIteratorBase< Type, DerivedType > Class Template Reference

Iterator over DataSequence2D types, over "fast" axis. CPU specific type. More...

#include <cheetah/data/DataSequence2DFastIterator.h>

Inheritance diagram for ska::cheetah::data::DataSequence2DFastIteratorBase< Type, DerivedType >:
Inheritance graph
Collaboration diagram for ska::cheetah::data::DataSequence2DFastIteratorBase< Type, DerivedType >:
Collaboration graph

Public Types

typedef std::iterator_traits< SelfType >::pointer PtrType
 
typedef std::iterator_traits< SelfType >::reference RefType
 
typedef std::iterator_traits< SelfType >::difference_type DiffType
 

Public Member Functions

 DataSequence2DFastIteratorBase (const DataSequence2D< Cpu, typename std::remove_cv< Type >::type > &data_ptr, std::size_t slow_offset=0)
 Create an iterator. More...
 
 DataSequence2DFastIteratorBase (DataSequence2D< Cpu, typename std::remove_cv< Type >::type > &data_ptr, std::size_t slow_offset=0)
 
 DataSequence2DFastIteratorBase ()
 default constructor. Required by random_access_iterator_tag
 
 DataSequence2DFastIteratorBase (const DataSequence2DFastIteratorBase< Type, DerivedType > &copy)
 copy constructor. Required by random_access_iterator_tag.
 
 ~DataSequence2DFastIteratorBase ()
 Destroy the iterator.
 
virtual PtrType operator-> () const
 dereference operators More...
 
virtual RefType operator* () const
 dereference operators
 
DerivedType & operator++ ()
 pre-increment operator. More...
 
DerivedType operator++ (int)
 post-increment the iterator to the next element in the data sequence More...
 
DerivedType & operator-- ()
 Decriment.
 
DerivedType operator-- (int)
 Decriment.
 
DerivedType & operator+= (DiffType off)
 Add-Asignment.
 
DerivedType & operator-= (DiffType off)
 Subtract-asignment.
 
DerivedType operator+ (DiffType off) const
 
DerivedType operator- (DiffType off) const
 
DiffType operator- (const SelfType &right) const
 
bool operator< (const SelfType &right) const
 
bool operator> (const SelfType &right) const
 
bool operator<= (const SelfType &right) const
 
bool operator>= (const SelfType &right) const
 
RefType operator[] (DiffType off) const
 Offset dereference.
 
bool operator== (SelfType const &) const
 return true if it is the same data and offset
 
bool operator!= (SelfType const &) const
 return true if it has neither the same data or offset
 

Protected Member Functions

std::size_t index ()
 

Protected Attributes

const DataSequence2D< Cpu, typename std::remove_cv< Type >::type > * _data
 
std::size_t _offset =0
 
Type * _raw
 

Detailed Description

template<typename Type, typename DerivedType>
class ska::cheetah::data::DataSequence2DFastIteratorBase< Type, DerivedType >

Iterator over DataSequence2D types, over "fast" axis. CPU specific type.

Template Parameters
TypeThe datatype stored in the DataSequence2D.

Definition at line 53 of file DataSequence2DFastIterator.h.

Constructor & Destructor Documentation

◆ DataSequence2DFastIteratorBase()

template<typename Type, typename DerivedType >
ska::cheetah::data::DataSequence2DFastIteratorBase< Type, DerivedType >::DataSequence2DFastIteratorBase ( const DataSequence2D< Cpu, typename std::remove_cv< Type >::type > &  data_ptr,
std::size_t  slow_offset = 0 
)
explicit

Create an iterator.

Iterator starts at the top of the "slow" axis given by slowOffset.

  • data_ptr the data to iterate over
  • slowOffset the slow axis offset, defaults to zero.

Definition at line 61 of file DataSequence2DFastIterator.cpp.

65 {
66  this->_data = &data_ptr;
67  this->_raw = data_ptr.data();
68  this->_offset = slow_offset*data_ptr.fast_axis_length();
69 }

Member Function Documentation

◆ operator+()

template<typename Type, typename DerivedType>
DerivedType ska::cheetah::data::DataSequence2DFastIteratorBase< Type, DerivedType >::operator+ ( DiffType  off) const

Add offset

Definition at line 127 of file DataSequence2DFastIterator.cpp.

128 {
129  DerivedType r(static_cast<DerivedType const&>(*this));
130  r._offset += off;
131  return r;
132 }

◆ operator++() [1/2]

template<typename Type , typename DerivedType >
DerivedType & ska::cheetah::data::DataSequence2DFastIteratorBase< Type, DerivedType >::operator++ ( )

pre-increment operator.

Returns
the iterator now pointing to the next element in the data sequence

at the end of the sequence will contain nullptr. Unlike the pot-increment operator, no copy is made.

Definition at line 88 of file DataSequence2DFastIterator.cpp.

88  {
89  ++(this->_offset);
90  return static_cast<DerivedType&>(*this);
91 }

◆ operator++() [2/2]

template<typename Type , typename DerivedType >
DerivedType ska::cheetah::data::DataSequence2DFastIteratorBase< Type, DerivedType >::operator++ ( int  )

post-increment the iterator to the next element in the data sequence

Returns
A copy of the iterator in its pre-incremented state.

Definition at line 95 of file DataSequence2DFastIterator.cpp.

95  {
96  DerivedType r(static_cast<DerivedType const&>(*this));
97  ++(this->_offset);
98  return r;
99 }

◆ operator-() [1/2]

template<typename Type, typename DerivedType>
DerivedType ska::cheetah::data::DataSequence2DFastIteratorBase< Type, DerivedType >::operator- ( DiffType  off) const

Subtract offset

◆ operator-() [2/2]

template<typename Type , typename DerivedType >
DataSequence2DFastIteratorBase< Type, DerivedType >::DiffType ska::cheetah::data::DataSequence2DFastIteratorBase< Type, DerivedType >::operator- ( const SelfType right) const

Subtract iterator

Definition at line 143 of file DataSequence2DFastIterator.cpp.

144 {
145  return this->_offset - right._offset;
146 }

◆ operator->()

template<typename Type , typename DerivedType >
DataSequence2DFastIteratorBase< Type, DerivedType >::PtrType ska::cheetah::data::DataSequence2DFastIteratorBase< Type, DerivedType >::operator-> ( ) const
virtual

dereference operators

return the actual data currently referenced by the iterator

Reimplemented in ska::cheetah::data::DataSequence2DPartialIterator< Cpu, Type >.

Definition at line 74 of file DataSequence2DFastIterator.cpp.

74  {
75  BOOST_ASSERT_MSG(this->_raw != nullptr,"Cannot dereference iterator over null DataSequence2D");
76  BOOST_ASSERT_MSG(this->_offset < this->_data->fast_axis_length()*this->_data->slow_axis_length(),"Cannot dereference post-end iterator");
77  return this->_raw+this->_offset;
78 }

◆ operator<()

template<typename Type , typename DerivedType >
bool ska::cheetah::data::DataSequence2DFastIteratorBase< Type, DerivedType >::operator< ( const SelfType right) const

less than

Definition at line 149 of file DataSequence2DFastIterator.cpp.

150 {
151  return this->_offset < right._offset;
152 }

◆ operator<=()

template<typename Type , typename DerivedType >
bool ska::cheetah::data::DataSequence2DFastIteratorBase< Type, DerivedType >::operator<= ( const SelfType right) const

Less than or Equal.

Definition at line 161 of file DataSequence2DFastIterator.cpp.

162 {
163  return this->_offset <= right._offset;
164 }

◆ operator>()

template<typename Type , typename DerivedType >
bool ska::cheetah::data::DataSequence2DFastIteratorBase< Type, DerivedType >::operator> ( const SelfType right) const

Greater Than

Definition at line 155 of file DataSequence2DFastIterator.cpp.

156 {
157  return this->_offset > right._offset;
158 }

◆ operator>=()

template<typename Type , typename DerivedType >
bool ska::cheetah::data::DataSequence2DFastIteratorBase< Type, DerivedType >::operator>= ( const SelfType right) const

Greater or Equal

Definition at line 167 of file DataSequence2DFastIterator.cpp.

167  {
168  return (this->_data==right._data) && (this->_offset >= right._offset);
169 }

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