geomc 1.0
A c++ linear algebra template library
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Friends | List of all members
GridIterator< T, N, Order > Class Template Reference

Iterator over the integer points in an N-dimensional grid. More...

#include <geomc/shape/GridIterator.h>

Inheritance diagram for GridIterator< T, N, Order >:

Public Types

typedef PointType< T, N >::point_t point_t
 Type of coordinate to be iterated over.
 

Public Member Functions

 GridIterator (const Rect< T, N > &r)
 
 GridIterator (const Rect< T, N > &r, const point_t &p)
 
 GridIterator (const point_t &lo, const point_t &hi)
 
GridIterator< T, N, Order > begin () const
 
GridIterator< T, N, Order > end () const
 

Public Attributes

const Rect< T, N > region
 Region over which to iterate.
 
point_t pt
 Current point.
 

Static Public Attributes

static constexpr ArrayOrder order = Order
 Array order (row-major or column-major)
 

Friends

class boost::iterator_core_access
 

Detailed Description

template<typename T, index_t N, ArrayOrder Order>
class geom::GridIterator< T, N, Order >

Iterator over the integer points in an N-dimensional grid.

Template Parameters
TType of coordinate (integer type recommended).
NDimension of rectangle to iterate over.
OrderRow- or column-major iteration.

This class accepts an N-dimensional rectangular region to iterate over, and returns points on the unit-spaced grid within than region. Row- or column-major order may be selected with the ArrayOrder template parameter.

GridIterators support all the standard operators expected of a random-access iterator:

GridIterator<int,3> i = ... ;
Vec<int,3> pt = *i;
++i; 
--i;
i += 10;
i1 - i2;
// etc.

Constructor & Destructor Documentation

◆ GridIterator() [1/3]

GridIterator ( const Rect< T, N > &  r)
inline

Construct an iterator over the region r pointing to the first grid point.

◆ GridIterator() [2/3]

GridIterator ( const Rect< T, N > &  r,
const point_t p 
)
inline

Construct an interator over the region r pointing at the point given by p.

Parameters
rA region
pA point inside r.

◆ GridIterator() [3/3]

GridIterator ( const point_t lo,
const point_t hi 
)
inline

Construct an iterator over the region bounded by the points lo and hi, pointing at the first cell.

Parameters
loLower extreme of the region (inclusive).
hiUpper extreme of the region (exclusive).

Member Function Documentation

◆ begin()

GridIterator< T, N, Order > begin ( ) const
inline
Returns
An iterator pointing to the lower-most coordinate of the grid

◆ end()

GridIterator< T, N, Order > end ( ) const
inline
Returns
An iterator pointing just beyond the upper-most coordinate of the grid.

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