|
#ifndef ARRAY2_H |
|
#define ARRAY2_H |
|
|
|
#include "Array1.h" |
|
#include <stdexcept> |
|
#include <string> |
|
|
|
class Array2 |
|
{ |
|
public: |
|
|
|
|
|
Array2(); |
|
|
|
|
|
Array2(int nrows, int ncols, long* data=0); |
|
|
|
|
|
Array2(const Array2 & source); |
|
|
|
|
|
~Array2(); |
|
|
|
|
|
Array2 & operator=(const Array2 & source); |
|
|
|
|
|
bool operator==(const Array2 & other) const; |
|
|
|
|
|
int nrows() const; |
|
int ncols() const; |
|
|
|
|
|
void resize(int nrows, int ncols, long* data=0); |
|
|
|
|
|
Array1 & operator[](int i); |
|
|
|
|
|
const Array1 & operator[](int i) const; |
|
|
|
|
|
std::string asString() const; |
|
|
|
|
|
void view(int* nrows, int* ncols, long** data) const; |
|
|
|
private: |
|
|
|
bool _ownData; |
|
int _nrows; |
|
int _ncols; |
|
long * _buffer; |
|
Array1 * _rows; |
|
|
|
|
|
void allocateMemory(); |
|
void allocateRows(); |
|
void deallocateMemory(); |
|
}; |
|
|
|
#endif |
|
|