/* $Id: array3.h,v 1.4 1996/11/06 11:37:47 roitzsch Exp $ */
#ifndef ARRAY3_TEMPLATE_H
#define ARRAY3_TEMPLATE_H
#include <stdlib.h>
#include "matrix.h"
// -------------------------- 3d - array -----------------------------
template<class T>
class Array3
{
public:
T*** layer;
int ll, lh, rl, rh, cl, ch;
Array3(int ll1,int lh1,int rl1,int rh1,int cl1,int ch1)
{ allocate (ll1, lh1, rl1, rh1, cl1, ch1); }
Array3(int nl, int nr, int nc)
{ allocate (1, nl, 1, nr, 1, nc); }
~Array3() { delete (layer[ll][rl]+cl);
delete (layer[ll]+rl);
delete (layer+ll);
}
T** operator() (int i)
{
if (CheckBoundsFlag) checkBounds(i);
return layer[i];
}
T* operator() (int i, int j)
{
if (CheckBoundsFlag) checkBounds(i,j);
return layer[i][j];
}
T& operator() (int i, int j, int k)
{
if (CheckBoundsFlag) checkBounds(i,j,k);
return layer[i][j][k];
}
int memSize();
int size();
void print() const;
// friend ostream& operator<< (ostream& s, Array3<T>& arr);
private:
void allocate (int ll1,int lh1,int rl1,int rh1,int cl1,int ch1);
void checkBounds(int i, int j, int k) const;
void checkBounds(int i, int j) const;
void checkBounds(int i) const;
Array3(Array3<T>& m);
Array3<T>& operator= (Array3<T>& m);
Array3<T>& operator= (T m);
void notImplemented(const char* s) const;
};
//-------------------------------------------------------------------------
#if INCLUDE_TEMPLATE_DEFS
#include "array3.c"
#endif
#endif
syntax highlighted by Code2HTML, v. 0.9.1