This class can be used for iterating a rectangular set of points, given its left and right bound. More...
#include <pointset.h>
Public Member Functions | |
tRectangle (const coordtype *_left=NULL, const coordtype *_right=NULL, int _dim=0) | |
The only possible constructor for new objects. | |
tRectangle (const tRectangle< coordtype > &r) | |
The copy constructor. | |
tRectangle & | operator= (const tRectangle< coordtype > &r) |
The assignment operator. | |
~tRectangle () | |
The destructor. | |
const coordtype * | get () |
Returns the next point in the recatngle. | |
void | reset () |
Resets the current point to the first one in the range. | |
Private Member Functions | |
void | initialize (const coordtype *_left=NULL, const coordtype *_right=NULL, int _dim=0) |
Initializes the internal data of an object of this class. | |
void | deallocate () |
Deallocates any memory previously allocated for this object. | |
Private Attributes | |
int | dim |
The dimension of the space. | |
const coordtype * | left |
A pointer to the left point (not allocated!). | |
const coordtype * | right |
A pointer to the right point (not allocated!). | |
coordtype * | point |
The coordinates of a created point. | |
int | firstpoint |
Should the 0 pointer be returned after the last point? |
This class can be used for iterating a rectangular set of points, given its left and right bound.
The source points must exist all the time you use this structure for these points, because they are not copied, only the addresses of their coordinate tables are stored. Example: "rectangle ([0,0], [2,2], 2)" represents a set of four points: [0,0], [0,1], [1,0] and [1,1].
Definition at line 1581 of file pointset.h.
chomp::homology::tRectangle< coordtype >::tRectangle | ( | const coordtype * | _left = NULL , |
|
const coordtype * | _right = NULL , |
|||
int | _dim = 0 | |||
) |
The only possible constructor for new objects.
Definition at line 1654 of file pointset.h.
References chomp::homology::tRectangle< coordtype >::initialize().
{ initialize (_left, _right, _dim); return; } /* tRectangle::tRectangle */
chomp::homology::tRectangle< coordtype >::tRectangle | ( | const tRectangle< coordtype > & | r | ) |
The copy constructor.
Definition at line 1662 of file pointset.h.
References chomp::homology::tRectangle< coordtype >::dim, chomp::homology::tRectangle< coordtype >::initialize(), chomp::homology::tRectangle< coordtype >::left, and chomp::homology::tRectangle< coordtype >::right.
{ initialize (r. left, r. right, r. dim); return; } /* tRectangle::tRectangle */
chomp::homology::tRectangle< coordtype >::~tRectangle< coordtype > | ( | ) |
The destructor.
void chomp::homology::tRectangle< coordtype >::deallocate | ( | ) | [private] |
Deallocates any memory previously allocated for this object.
Definition at line 1677 of file pointset.h.
References chomp::homology::tRectangle< coordtype >::point.
Referenced by chomp::homology::tRectangle< coordtype >::operator=().
const coordtype * chomp::homology::tRectangle< coordtype >::get | ( | ) |
Returns the next point in the recatngle.
If no more points are available then returns 0 and rewinds to the first point.
Definition at line 1701 of file pointset.h.
References chomp::homology::tRectangle< coordtype >::dim, chomp::homology::tRectangle< coordtype >::firstpoint, chomp::homology::tRectangle< coordtype >::left, chomp::homology::tRectangle< coordtype >::point, and chomp::homology::tRectangle< coordtype >::right.
{ // if this is the first point, check if the rectangle is nonempty if (firstpoint) { firstpoint = 0; for (int i = 0; i < dim; ++ i) if (left [i] >= right [i]) return NULL; return point; } // compute the next point of the rectangle int cur = 0; while ((cur < dim) && (++ (point [cur]) >= right [cur])) { point [cur] = left [cur]; ++ cur; } // if the iterator has run out of points, return NULL if (cur >= dim) { firstpoint = 1; return NULL; } // return the point's coordinates return point; } /* tRectangle::get */
void chomp::homology::tRectangle< coordtype >::initialize | ( | const coordtype * | _left = NULL , |
|
const coordtype * | _right = NULL , |
|||
int | _dim = 0 | |||
) | [private] |
Initializes the internal data of an object of this class.
Definition at line 1632 of file pointset.h.
References chomp::homology::tRectangle< coordtype >::dim, chomp::homology::tRectangle< coordtype >::firstpoint, chomp::homology::tRectangle< coordtype >::left, chomp::homology::tRectangle< coordtype >::point, chomp::homology::tRectangle< coordtype >::reset(), and chomp::homology::tRectangle< coordtype >::right.
Referenced by chomp::homology::tRectangle< coordtype >::operator=(), and chomp::homology::tRectangle< coordtype >::tRectangle().
tRectangle< coordtype > & chomp::homology::tRectangle< coordtype >::operator= | ( | const tRectangle< coordtype > & | r | ) |
The assignment operator.
Definition at line 1669 of file pointset.h.
References chomp::homology::tRectangle< coordtype >::deallocate(), chomp::homology::tRectangle< coordtype >::dim, chomp::homology::tRectangle< coordtype >::initialize(), chomp::homology::tRectangle< coordtype >::left, and chomp::homology::tRectangle< coordtype >::right.
{ deallocate (); initialize (r. left, r. right, r. dim); return *this; } /* tRectangle::operator = */
void chomp::homology::tRectangle< coordtype >::reset | ( | void | ) |
Resets the current point to the first one in the range.
Definition at line 1692 of file pointset.h.
References chomp::homology::tRectangle< coordtype >::dim, chomp::homology::tRectangle< coordtype >::firstpoint, chomp::homology::tRectangle< coordtype >::left, and chomp::homology::tRectangle< coordtype >::point.
Referenced by chomp::homology::tRectangle< coordtype >::initialize().
{ for (int i = 0; i < dim; ++ i) point [i] = left [i]; firstpoint = 1; return; } /* tRectangle::reset */
int chomp::homology::tRectangle< coordtype >::dim [private] |
The dimension of the space.
Definition at line 1606 of file pointset.h.
Referenced by chomp::homology::tRectangle< coordtype >::get(), chomp::homology::tRectangle< coordtype >::initialize(), chomp::homology::tRectangle< coordtype >::operator=(), chomp::homology::tRectangle< coordtype >::reset(), and chomp::homology::tRectangle< coordtype >::tRectangle().
int chomp::homology::tRectangle< coordtype >::firstpoint [private] |
Should the 0 pointer be returned after the last point?
Definition at line 1618 of file pointset.h.
Referenced by chomp::homology::tRectangle< coordtype >::get(), chomp::homology::tRectangle< coordtype >::initialize(), and chomp::homology::tRectangle< coordtype >::reset().
const coordtype* chomp::homology::tRectangle< coordtype >::left [private] |
A pointer to the left point (not allocated!).
Definition at line 1609 of file pointset.h.
Referenced by chomp::homology::tRectangle< coordtype >::get(), chomp::homology::tRectangle< coordtype >::initialize(), chomp::homology::tRectangle< coordtype >::operator=(), chomp::homology::tRectangle< coordtype >::reset(), and chomp::homology::tRectangle< coordtype >::tRectangle().
coordtype* chomp::homology::tRectangle< coordtype >::point [private] |
The coordinates of a created point.
Definition at line 1615 of file pointset.h.
Referenced by chomp::homology::tRectangle< coordtype >::deallocate(), chomp::homology::tRectangle< coordtype >::get(), chomp::homology::tRectangle< coordtype >::initialize(), and chomp::homology::tRectangle< coordtype >::reset().
const coordtype* chomp::homology::tRectangle< coordtype >::right [private] |
A pointer to the right point (not allocated!).
Definition at line 1612 of file pointset.h.
Referenced by chomp::homology::tRectangle< coordtype >::get(), chomp::homology::tRectangle< coordtype >::initialize(), chomp::homology::tRectangle< coordtype >::operator=(), and chomp::homology::tRectangle< coordtype >::tRectangle().