| 1 |
#ifndef ARRAY1_H |
| 2 |
#define ARRAY1_H |
| 3 |
|
| 4 |
#include <stdexcept> |
| 5 |
#include <string> |
| 6 |
|
| 7 |
class Array1 |
| 8 |
{ |
| 9 |
public: |
| 10 |
|
| 11 |
// Default/length/array constructor |
| 12 |
Array1(int length = 0, long* data = 0); |
| 13 |
|
| 14 |
// Copy constructor |
| 15 |
Array1(const Array1 & source); |
| 16 |
|
| 17 |
// Destructor |
| 18 |
~Array1(); |
| 19 |
|
| 20 |
// Assignment operator |
| 21 |
Array1 & operator=(const Array1 & source); |
| 22 |
|
| 23 |
// Equals operator |
| 24 |
bool operator==(const Array1 & other) const; |
| 25 |
|
| 26 |
// Length accessor |
| 27 |
int length() const; |
| 28 |
|
| 29 |
// Resize array |
| 30 |
void resize(int length, long* data = 0); |
| 31 |
|
| 32 |
// Set item accessor |
| 33 |
long & operator[](int i); |
| 34 |
|
| 35 |
// Get item accessor |
| 36 |
const long & operator[](int i) const; |
| 37 |
|
| 38 |
// String output |
| 39 |
std::string asString() const; |
| 40 |
|
| 41 |
// Get view |
| 42 |
void view(long** data, int* length) const; |
| 43 |
|
| 44 |
private: |
| 45 |
// Members |
| 46 |
bool _ownData; |
| 47 |
int _length; |
| 48 |
long * _buffer; |
| 49 |
|
| 50 |
// Methods |
| 51 |
void allocateMemory(); |
| 52 |
void deallocateMemory(); |
| 53 |
}; |
| 54 |
|
| 55 |
#endif |