IBAMR  IBAMR version 0.19.
Public Types | Public Member Functions | Protected Types | Protected Attributes | Private Member Functions | Friends | List of all members
MDA_IndexRange< MDA_DIM > Class Template Reference

Defines index ranges for multidimensional arrays. More...

#include <MDA_Access.h>

Inheritance diagram for MDA_IndexRange< MDA_DIM >:
Inheritance graph
[legend]

Public Types

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

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. More...
 
 MDA_IndexRange (const index_t *si, const index_t *sf)
 Constructor for setting index data to a range. More...
 
virtual ~MDA_IndexRange ()
 Virtual destructor to support inheritance. More...
 
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. More...
 
bool operator== (const MDA_IndexRange &r) const
 Equivalence comparison. More...
 
bool operator!= (const MDA_IndexRange &r) const
 Inequivalence comparison. More...
 
std::ostream & streamPut (std::ostream &os) const
 Output to ostream. More...
 
std::istream & streamGet (std::istream &is)
 Input from istream. More...
 
const index_tbeg (size_t i) const
 Give starting index of a given dimension. More...
 
const index_tend (size_t i) const
 Give ending index (one more than the last valid index) of a given dimension. More...
 
const size_t & size (size_t i) const
 Give size along a given dimension. More...
 
size_t totalSize () const
 Give size for all dimensions. More...
 
bool has (index_t i0) const
 Check if indices are in range. More...
 
bool has (index_t i0, index_t i1) const
 Check if indices are in range. More...
 
bool has (index_t i0, index_t i1, index_t i2) const
 Check if indices are in range. More...
 
bool has (index_t i0, index_t i1, index_t i2, index_t i3) const
 Check if indices are in range. More...
 

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. More...
 
index_t d_stop [MDA_DIM >0?MDA_DIM:1]
 Array of stopping indices. More...
 
size_t d_size [MDA_DIM >0?MDA_DIM:1]
 Array of sizes. More...
 

Private Member Functions

void setDependentData ()
 Set dependent data. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const MDA_IndexRange< MDA_DIM > &r)
 
std::istream & operator>> (std::istream &is, MDA_IndexRange< MDA_DIM > &r)
 

Detailed Description

template<unsigned short MDA_DIM>
class MDA_IndexRange< MDA_DIM >

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

Nothing is known about the ordering of the array.

Member Typedef Documentation

◆ dim_t

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

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).

◆ index_t

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

Member Enumeration Documentation

◆ anonymous enum

template<unsigned short MDA_DIM>
anonymous enum
protected
Enumerator
D0 
D1 
D2 
D3 
D4 

Constructor & Destructor Documentation

◆ MDA_IndexRange() [1/2]

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

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

  • Array sizes are 0
  • Array starting indices are 0 Since all arguments have default values, this serves at the default constructor.

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
szArray sizes
stArray starting indices

◆ MDA_IndexRange() [2/2]

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

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
siArray of initial indices
sfArray of final indices

◆ ~MDA_IndexRange()

template<unsigned short MDA_DIM>
virtual MDA_IndexRange< MDA_DIM >::~MDA_IndexRange ( )
inlinevirtual

Member Function Documentation

◆ setSizeAndStart()

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
szArray sizes (NULL for no change)
stStarting indices (NULL for no change)

◆ setInclusiveRange()

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
firstFirst valid indices (NULL for no change)
finalFinal valid indices (NULL for no change)

◆ adjustDim()

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 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
dDimension to adjust
firstIncrement to first index
finalIncrement to final index

◆ operator==()

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

◆ operator!=()

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

◆ streamPut()

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

◆ streamGet()

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

◆ beg()

template<unsigned short MDA_DIM>
const index_t& MDA_IndexRange< MDA_DIM >::beg ( size_t  i) const
inline
Parameters
iindex of dimension

◆ end()

template<unsigned short MDA_DIM>
const index_t& MDA_IndexRange< MDA_DIM >::end ( size_t  i) const
inline
Parameters
iindex of dimension

◆ size()

template<unsigned short MDA_DIM>
const size_t& MDA_IndexRange< MDA_DIM >::size ( size_t  i) const
inline
Parameters
iindex of dimension

◆ totalSize()

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

◆ has() [1/4]

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

◆ has() [2/4]

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

◆ has() [3/4]

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

◆ has() [4/4]

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

◆ setDependentData()

template<unsigned short MDA_DIM>
void MDA_IndexRange< MDA_DIM >::setDependentData ( )
inlineprivate

Friends And Related Function Documentation

◆ operator<<

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

◆ operator>>

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

Member Data Documentation

◆ d_start

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

◆ d_stop

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

◆ d_size

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

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