P
Peter Olcott
//
// Array2D.h 2005-11-27 5:50 AM
//
#define UINT unsigned int
//
//
//
class ArrayType2D {
private:
int Width;
int Height;
int Size;
UINT* Array;
bool Allocated;
void Copy(ArrayType2D& Array2);
public:
ArrayType2D();
ArrayType2D(ArrayType2D& Array2) { Copy(Array2); };
~ArrayType2D() { if (Allocated) delete [] Array; };
UINT& operator()(const UINT ROW, const UINT COL) { return Array[ROW * Width + COL]; }
ArrayType2D& operator=(ArrayType2D& Array2) { Copy(Array2); return *this; };
UINT* operator&() { return Array; };
const int width() { return Width; };
const int height() { return Height; };
void Allocate(int Height, int Width);
};
void ArrayType2D::Copy(ArrayType2D& Array2) {
if (this->Allocated)
delete [] Array;
this->Width = Array2.Width;
this->Height = Array2.Height;
this->Size = Array2.Size;
this->Array = new UINT [Size];
for (int N = 0; N < Size; N++)
Array[N] = Array2.Array[N];
this->Allocated = true;
}
ArrayType2D::ArrayType2D() {
Width = 0;
Height = 0;
Size = 0;
Array = NULL;
Allocated = false;
}
inline void ArrayType2D::Allocate(int Height, int Width) {
if (Allocated)
delete [] Array;
this->Width = Width;
this->Height = Height;
this->Size = Width * Height;
this->Array = new UINT [Size];
this->Allocated = true;
}
// Array2D.h 2005-11-27 5:50 AM
//
#define UINT unsigned int
//
//
//
class ArrayType2D {
private:
int Width;
int Height;
int Size;
UINT* Array;
bool Allocated;
void Copy(ArrayType2D& Array2);
public:
ArrayType2D();
ArrayType2D(ArrayType2D& Array2) { Copy(Array2); };
~ArrayType2D() { if (Allocated) delete [] Array; };
UINT& operator()(const UINT ROW, const UINT COL) { return Array[ROW * Width + COL]; }
ArrayType2D& operator=(ArrayType2D& Array2) { Copy(Array2); return *this; };
UINT* operator&() { return Array; };
const int width() { return Width; };
const int height() { return Height; };
void Allocate(int Height, int Width);
};
void ArrayType2D::Copy(ArrayType2D& Array2) {
if (this->Allocated)
delete [] Array;
this->Width = Array2.Width;
this->Height = Array2.Height;
this->Size = Array2.Size;
this->Array = new UINT [Size];
for (int N = 0; N < Size; N++)
Array[N] = Array2.Array[N];
this->Allocated = true;
}
ArrayType2D::ArrayType2D() {
Width = 0;
Height = 0;
Size = 0;
Array = NULL;
Allocated = false;
}
inline void ArrayType2D::Allocate(int Height, int Width) {
if (Allocated)
delete [] Array;
this->Width = Width;
this->Height = Height;
this->Size = Width * Height;
this->Array = new UINT [Size];
this->Allocated = true;
}