MDA_IndexRange< MDA_DIM > Class Template Reference

Defines index ranges for multidimensional arrays. More...

#include <source/patchdata/array/array_access/MDA_Access.h>

Inheritance diagram for MDA_IndexRange< MDA_DIM >:

Inheritance graph
[legend]
List of all members.
std::ostream & streamPut (std::ostream &os) const
 Output to ostream.
std::istream & streamGet (std::istream &is)
 Input from istream.
std::ostream & operator<< (std::ostream &os, const MDA_IndexRange< MDA_DIM > &r)
std::istream & operator>> (std::istream &is, MDA_IndexRange< MDA_DIM > &r)

Public Types

typedef short dim_t
 Type for the dimension counter.
typedef int index_t
 Type for the index.

Public Member Functions

 MDA_IndexRange (const size_t *sz=((size_t *) 0), const index_t *st=((index_t *) 0))
 Constructor for setting index data using size and starting points.
 MDA_IndexRange (const index_t *si, const index_t *sf)
 Constructor for setting index data to a range.
virtual ~MDA_IndexRange ()
 Virtual destructor to support inheritance.
void setSizeAndStart (const size_t *sz=((size_t *) 0), const index_t *st=((index_t *) 0))
void setInclusiveRange (const index_t first[MDA_DIM], const index_t final[MDA_DIM])
const MDA_IndexRangeadjustDim (dim_t d, index_t first, index_t final)
 Adjust the dimensions.
bool operator== (const MDA_IndexRange &r) const
 Equivalence comparison.
bool operator!= (const MDA_IndexRange &r) const
 Inequivalence comparison.
const index_tbeg (size_t i) const
 Give starting index of a given dimension.
const index_tend (size_t i) const
 Give ending index (one more than the last valid index) of a given dimension.
const size_t & size (size_t i) const
 Give size along a given dimension.
size_t totalSize () const
 Give size for all dimensions.
bool has (index_t i0) const
 Check if indices are in range.
bool has (index_t i0, index_t i1) const
 Check if indices are in range.
bool has (index_t i0, index_t i1, index_t i2) const
 Check if indices are in range.
bool has (index_t i0, index_t i1, index_t i2, index_t i3) const
 Check if indices are in range.

Protected Types

enum  {
  D0 = 0, D1 = (MDA_DIM > 1 ? 1 : 0), D2 = (MDA_DIM > 2 ? 2 : 0), D3 = (MDA_DIM > 3 ? 3 : 0),
  D4 = (MDA_DIM > 4 ? 4 : 0)
}
 Dimension number (to avoid compiler warnings, set to zero when unused). More...

Protected Attributes

index_t d_start [MDA_DIM >0?MDA_DIM:1]
 Array of starting indices.
index_t d_stop [MDA_DIM >0?MDA_DIM:1]
 Array of stopping indices.
size_t d_size [MDA_DIM >0?MDA_DIM:1]
 Array of sizes.

Detailed Description

template<unsigned short MDA_DIM>
class MDA_IndexRange< MDA_DIM >

Defines index ranges for multidimensional arrays.

Defines the abstract index range and methods for setting and accessing it.

Nothing is known about the ordering of the array.


Member Typedef Documentation

template<unsigned short MDA_DIM>
typedef short MDA_IndexRange< MDA_DIM >::dim_t

Type for the dimension counter.

Type dim_t could be "unsigned short" instead of "short", but using short causes the GNU compiler to issue unneeded warnings about certain comparisons always being false (when instantiating with MDA_DIM of 1).

Reimplemented in MDA_OrderRowMajor< MDA_DIM >, and MDA_OrderColMajor< MDA_DIM >.

template<unsigned short MDA_DIM>
typedef int MDA_IndexRange< MDA_DIM >::index_t

Type for the index.

Reimplemented in MDA_OrderRowMajor< MDA_DIM >, and MDA_OrderColMajor< MDA_DIM >.


Member Enumeration Documentation

template<unsigned short MDA_DIM>
anonymous enum [protected]

Dimension number (to avoid compiler warnings, set to zero when unused).

Enumerator:
D0 
D1 
D2 
D3 
D4 


Constructor & Destructor Documentation

template<unsigned short MDA_DIM>
MDA_IndexRange< MDA_DIM >::MDA_IndexRange ( const size_t *  sz = ((size_t*)0),
const index_t st = ((index_t*)0) 
) [inline]

Constructor for setting index data using size and starting points.

Any pointers that are NULL are not used. The resulting default settings are:

There is another constructor which accepts the first and final indices instead of the sizes and first indices. NOTE: the place of the starting points is different than it is for the constructor taking final indices instead of sizes.

Parameters:
sz  Array sizes
st  Array starting indices

template<unsigned short MDA_DIM>
MDA_IndexRange< MDA_DIM >::MDA_IndexRange ( const index_t si,
const index_t sf 
) [inline]

Constructor for setting index data to a range.

This version takes two index_t* arguments, for the initial and final indices. It does not support default arguments until after the indices argument. NOTE: the place of the initial indices is different than it is for the constructor taking sizes instead of final indices.

If si is NULL, starting indices are set to 0. If sf is NULL, sizes are set to zero.

Parameters:
si  Array of initial indices
sf  Array of final indices

template<unsigned short MDA_DIM>
virtual MDA_IndexRange< MDA_DIM >::~MDA_IndexRange (  )  [inline, virtual]

Virtual destructor to support inheritance.


Member Function Documentation

template<unsigned short MDA_DIM>
void MDA_IndexRange< MDA_DIM >::setSizeAndStart ( const size_t *  sz = ((size_t*)0),
const index_t st = ((index_t*)0) 
) [inline]

Set size and starting indices.

Parameters:
sz  Array sizes (NULL for no change)
st  Starting indices (NULL for no change)

Reimplemented in MDA_OrderRowMajor< MDA_DIM >, and MDA_OrderColMajor< MDA_DIM >.

template<unsigned short MDA_DIM>
void MDA_IndexRange< MDA_DIM >::setInclusiveRange ( const index_t  first[MDA_DIM],
const index_t  final[MDA_DIM] 
) [inline]

Set first and final indices (inclusive).

Parameters:
first  First valid indices (NULL for no change)
final  Final valid indices (NULL for no change)

Reimplemented in MDA_OrderRowMajor< MDA_DIM >, and MDA_OrderColMajor< MDA_DIM >.

template<unsigned short MDA_DIM>
const MDA_IndexRange& MDA_IndexRange< MDA_DIM >::adjustDim ( dim_t  d,
index_t  first,
index_t  final 
) [inline]

Adjust the dimensions.

Adjust the first and final indices. Set the dimension to adjust to >= MDA_DIM to adjust all dimensions. Note: The third argument is the increment to the final index and not the size.

Note: No error checking is done, for example, to make sure that the resulting size is non-negative.

Returns:
Adjusted MDA_IndexRange object
Parameters:
d  Dimension to adjust
first  Increment to first index
final  Increment to final index

template<unsigned short MDA_DIM>
bool MDA_IndexRange< MDA_DIM >::operator== ( const MDA_IndexRange< MDA_DIM > &  r  )  const [inline]

Equivalence comparison.

template<unsigned short MDA_DIM>
bool MDA_IndexRange< MDA_DIM >::operator!= ( const MDA_IndexRange< MDA_DIM > &  r  )  const [inline]

Inequivalence comparison.

template<unsigned short MDA_DIM>
std::ostream& MDA_IndexRange< MDA_DIM >::streamPut ( std::ostream &  os  )  const [inline]

Output to ostream.

template<unsigned short MDA_DIM>
std::istream& MDA_IndexRange< MDA_DIM >::streamGet ( std::istream &  is  )  [inline]

Input from istream.

template<unsigned short MDA_DIM>
const index_t& MDA_IndexRange< MDA_DIM >::beg ( size_t  i  )  const [inline]

Give starting index of a given dimension.

Parameters:
i  index of dimension

template<unsigned short MDA_DIM>
const index_t& MDA_IndexRange< MDA_DIM >::end ( size_t  i  )  const [inline]

Give ending index (one more than the last valid index) of a given dimension.

Parameters:
i  index of dimension

template<unsigned short MDA_DIM>
const size_t& MDA_IndexRange< MDA_DIM >::size ( size_t  i  )  const [inline]

Give size along a given dimension.

Parameters:
i  index of dimension

template<unsigned short MDA_DIM>
size_t MDA_IndexRange< MDA_DIM >::totalSize (  )  const [inline]

Give size for all dimensions.

template<unsigned short MDA_DIM>
bool MDA_IndexRange< MDA_DIM >::has ( index_t  i0  )  const [inline]

Check if indices are in range.

template<unsigned short MDA_DIM>
bool MDA_IndexRange< MDA_DIM >::has ( index_t  i0,
index_t  i1 
) const [inline]

Check if indices are in range.

template<unsigned short MDA_DIM>
bool MDA_IndexRange< MDA_DIM >::has ( index_t  i0,
index_t  i1,
index_t  i2 
) const [inline]

Check if indices are in range.

template<unsigned short MDA_DIM>
bool MDA_IndexRange< MDA_DIM >::has ( index_t  i0,
index_t  i1,
index_t  i2,
index_t  i3 
) const [inline]

Check if indices are in range.


Friends And Related Function Documentation

template<unsigned short MDA_DIM>
std::ostream& operator<< ( std::ostream &  os,
const MDA_IndexRange< MDA_DIM > &  r 
) [friend]

template<unsigned short MDA_DIM>
std::istream& operator>> ( std::istream &  is,
MDA_IndexRange< MDA_DIM > &  r 
) [friend]


Member Data Documentation

template<unsigned short MDA_DIM>
index_t MDA_IndexRange< MDA_DIM >::d_start[MDA_DIM >0?MDA_DIM:1] [protected]

Array of starting indices.

template<unsigned short MDA_DIM>
index_t MDA_IndexRange< MDA_DIM >::d_stop[MDA_DIM >0?MDA_DIM:1] [protected]

Array of stopping indices.

template<unsigned short MDA_DIM>
size_t MDA_IndexRange< MDA_DIM >::d_size[MDA_DIM >0?MDA_DIM:1] [protected]

Array of sizes.


The documentation for this class was generated from the following file:
Generated on Thu Jun 18 11:28:18 2009 for SAMRAI by  doxygen 1.5.1