SCPPNT::Region2D_iterator< T, IT2D > Class Template Reference

Foward iterator over all elements of a matrix region. More...

#include <region2d.h>

List of all members.

Public Types

typedef T value_type
 Type of element pointed to.
typedef std::forward_iterator_tag iterator_category
 Only allows forward iteration.
typedef Subscript difference_type
 Type for number of elements separating two iterators.
typedef std::iterator_traits
< iterator_2D >::value_type 
iterator_1D
 Iterator over row or column iterators.
typedef std::iterator_traits
< iterator_1D >::pointer 
pointer
 Iterator over row or column elements.
typedef std::iterator_traits
< iterator_1D >::reference 
reference
 Pointer to type.

Public Member Functions

 Region2D_iterator (IT2D it, Subscript n2d, Subscript n1d, Subscript initial2=1, Subscript initial1=1)
 Reference to type pointed to.
reference operator * () const
 Return reference to current element pointed to.
Region2D_iteratoroperator++ ()
 Increment to point to next element and return modified Region2D_iterator (preincrement).
Region2D_iterator operator++ (int)
 Increment to point to next element and return Region2D_iterator pointing to original element (postincrement).

Friends

bool operator== (const Region2D_iterator< T, IT2D > &lhs, const Region2D_iterator< T, IT2D > &rhs)
 Returns true if two Region2D_iterator objects point to the same element.
bool operator!= (const Region2D_iterator< T, IT2D > &lhs, const Region2D_iterator< T, IT2D > &rhs)
 Returns true if two Region2D_iterator objects point to the different elements.


Detailed Description

template<class T, class IT2D>
class SCPPNT::Region2D_iterator< T, IT2D >

Foward iterator over all elements of a matrix region.

Foward iterator over all elements of a matrix region. Can be used to define an iterator over all elements of a matrix in either row-major or column-major order. For instance, Region2D_iterator<double, Matrix<double>::columns_iterator> will be an iterator over all elements of a matrix in column-major order even if the elements of the matrix are stored in row-major order.

Parameters:
T Type of elements iterator points to. This is not the same as iterator_traits<iterator_traits<IT2D>::value_type>value_type if IT2D is a constant iterator (e.g., Matrix<T>::const_rows_iterator).
IT2D A two dimensional iterator (iterator over iterators to row elements or iterator over iterators to column elements). Possible values of this parameter are: Matrix<T>::rows_iterator, Matrix<T>::columns_iterator, Matrix<T>::const_rows_iterator, Matrix<T>::const_columns_iterator. This parameter determines whether the order of iteration is row-major or column-major.
The techinique used for logical comparison operators that allow constant types to be compared with non-constant types is described in:

Austern, Matt (2001, January). Defining iterators and const iterators. C/C++ Users Journal (www.cuj.com), 74-79.

Definition at line 95 of file region2d.h.


Constructor & Destructor Documentation

template<class T, class IT2D>
SCPPNT::Region2D_iterator< T, IT2D >::Region2D_iterator ( IT2D  it,
Subscript  n2d,
Subscript  n1d,
Subscript  initial2 = 1,
Subscript  initial1 = 1 
) [inline]

Reference to type pointed to.

Constructor.

Constructor. Second and third arguments are 1-based indices of initial element iterator points to.

Parameters:
it Iterator over row iterators or column iterators.
n2d Number of valid elements pointed to by it.
n1d Number of valid elements pointed to by each of the iterators it[0], it[1], etc.
initial2 Initial element for 2D iterator (one-offset)
initial1 Initial element for each 1D iterator (one-offset)

Definition at line 216 of file region2d.h.

00217                                                                             :
00218     i2D_(it), n1D_(n1d)
00219   {
00220     if (initial2 >= n2d || initial1 >= n1d)
00221       throw BadDimension("SCPPNT::Region2D_iterator::region2D_iterator");
00222     end2D_ = it + n2d;
00223     i2D_ += initial2 - 1;
00224     end_ = *i2D_ + n1D_;
00225     current_ = *i2D_ + initial1 - 1;
00226   }


The documentation for this class was generated from the following file:
Generated on Tue Dec 18 23:34:32 2007 for SCPPNT by  doxygen 1.5.4