dlr::numeric::Index2D Class Reference

The Index2D class represents a 2 dimensional index in (row, column) format, such as (0, 1), (23, 7), or (-4, 2). More...

#include <index2D.h>

List of all members.

Public Member Functions

 Index2D ()
 The default constructor initializes to (0, 0).
 Index2D (int row, int column)
 This constructor explicitly sets the indices.
 Index2D (const Index2D &other)
 The copy constructor deep copies its argument.
 ~Index2D ()
 The destructor destroys the Index2D instance.
void setValue (int row, int column)
 This member function explicitly sets the sets the indices.
int getColumn () const
 This member function returns the first component of the Index2D by value.
int getRow () const
 This member function returns the second component of the Index2D by value.
int getU () const
 This member function returns the first component of the Index2D by value.
int getV () const
 This member function returns the second component of the Index2D by value.
Index2Doperator= (const Index2D &other)
 The assignment operator deep copies its argument.
int operator[] (size_t index) const
 WARNING: this operator has confusing semantics, as illustrated by this example, in which all assertions pass:.
Index2Doperator*= (int scalar)
 This operator multiplies each component of the Index2D instance by a scalar.
Index2Doperator/= (int scalar)
 This operator divides each component of the Index2D instance by a scalar.
Index2Doperator+= (const Index2D &other)
 This operator adds a scalar to each component of the Index2D instance.
Index2Doperator-= (const Index2D &other)
 This operator subtracts a scalar from each component of the Index2D instance.
Index2D operator- ()
 This operator returns an Index2D equal to *this, but with each element negated.


Detailed Description

The Index2D class represents a 2 dimensional index in (row, column) format, such as (0, 1), (23, 7), or (-4, 2).

An alternate way to think of this class is as a point with integer coordinates in a (U, V) coordinate system, where the origin lies at row = 0, column = 0, the U axis points along the first row, and the V axis points along the first column. Note that by this definition, the value of U is equal to the column index, and the value of V is equal to the row index. This leads to some confusing ordering issues. For example, the value returned by Index2D(1, 2).getU() is 2, and the value returned by Index2D(1, 2).getV() is 1.

WARNING: be particularly careful with Index2D::operator[](size_t), as illustrated by this example, in which all assertions pass:

   Index2D exampleIndex(1, 2);
   assert(exampleIndex[0] == exampleIndex.getU());
   assert(exampleIndex[0] == 2);
   assert(exampleIndex[1] == exampleIndex.getU());
   assert(exampleIndex[1] == 1);

Definition at line 50 of file index2D.h.


Constructor & Destructor Documentation

dlr::numeric::Index2D::Index2D (  )  [inline]

The default constructor initializes to (0, 0).

Definition at line 56 of file index2D.h.

Referenced by operator-().

dlr::numeric::Index2D::Index2D ( int  row,
int  column 
) [inline]

This constructor explicitly sets the indices.

Parameters:
uIndex The first component of the Index2D.
uIndex The second component of the Index2D.

Definition at line 67 of file index2D.h.

dlr::numeric::Index2D::Index2D ( const Index2D other  )  [inline]

The copy constructor deep copies its argument.

Parameters:
other This argument is the Index2D instance to be copied.

Definition at line 77 of file index2D.h.

dlr::numeric::Index2D::~Index2D (  )  [inline]

The destructor destroys the Index2D instance.

Definition at line 84 of file index2D.h.


Member Function Documentation

int dlr::numeric::Index2D::getColumn (  )  const [inline]

int dlr::numeric::Index2D::getRow (  )  const [inline]

int dlr::numeric::Index2D::getU (  )  const [inline]

This member function returns the first component of the Index2D by value.

It is a synonym for member function getColumn().

Returns:
The return value is the first (U) coordinate.

Definition at line 123 of file index2D.h.

References getColumn().

int dlr::numeric::Index2D::getV (  )  const [inline]

This member function returns the second component of the Index2D by value.

It is a synonym for member function getRow().

Returns:
The return value is the second (V) coordinate.

Definition at line 132 of file index2D.h.

References getRow().

Index2D& dlr::numeric::Index2D::operator*= ( int  scalar  )  [inline]

This operator multiplies each component of the Index2D instance by a scalar.

Parameters:
scalar This argument is the scalar by which to multiply.
Returns:
The return value is a reference to *this after the operation has been performed.

Definition at line 190 of file index2D.h.

Index2D& dlr::numeric::Index2D::operator+= ( const Index2D other  )  [inline]

This operator adds a scalar to each component of the Index2D instance.

Parameters:
scalar This argument is the scalar to be added.
Returns:
The return value is a reference to *this after the operation has been performed.

Definition at line 222 of file index2D.h.

References m_column, and m_row.

Index2D dlr::numeric::Index2D::operator- (  )  [inline]

This operator returns an Index2D equal to *this, but with each element negated.

Returns:
The return value is a negated copy of *this.

Definition at line 247 of file index2D.h.

References Index2D().

Index2D& dlr::numeric::Index2D::operator-= ( const Index2D other  )  [inline]

This operator subtracts a scalar from each component of the Index2D instance.

Parameters:
scalar This argument is the scalar to be subtracted.
Returns:
The return value is a reference to *this after the operation has been performed.

Definition at line 236 of file index2D.h.

References m_column, and m_row.

Index2D& dlr::numeric::Index2D::operator/= ( int  scalar  )  [inline]

This operator divides each component of the Index2D instance by a scalar.

Parameters:
scalar This argument is the scalar by which to divide.
Returns:
The return value is a reference to *this after the operation has been performed.

Definition at line 204 of file index2D.h.

Index2D& dlr::numeric::Index2D::operator= ( const Index2D other  )  [inline]

The assignment operator deep copies its argument.

Parameters:
other This argument is the Index2D instance to be copied.
Returns:
The return value is a reference to *this after the operation has been performed.

Definition at line 144 of file index2D.h.

References m_column, m_row, and setValue().

int dlr::numeric::Index2D::operator[] ( size_t  index  )  const [inline]

WARNING: this operator has confusing semantics, as illustrated by this example, in which all assertions pass:.

   Index2D exampleIndex(1, 2);
   assert(exampleIndex[0] == exampleIndex.getU());
   assert(exampleIndex[0] == 2);
   assert(exampleIndex[1] == exampleIndex.getU());
   assert(exampleIndex[1] == 1);

The indexing operator returns a reference to the U or V component of *this as if *this were a two element array. Out of bounds indices will return the V component.

Parameters:
index This argument is the index into *this. An index of 0 means to return the "U" component, where the U axis is parallel to the first row of the indexed array. In other words, an index of 0 means to return the column value.
Returns:
The return value is the selected component of *this.

Definition at line 173 of file index2D.h.

References getColumn(), and getRow().

void dlr::numeric::Index2D::setValue ( int  row,
int  column 
) [inline]

This member function explicitly sets the sets the indices.

Parameters:
row The first component of the Index2D.
column The second component of the Index2D.

Definition at line 94 of file index2D.h.

Referenced by operator=(), dlr::numeric::operator>>(), and dlr::numeric::BoxIntegrator2D< Type0, Type1 >::setArray().


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

Generated on Wed Nov 25 00:42:49 2009 for dlrUtilities Utility Library by  doxygen 1.5.8