Debian Codegraph @

tools/swig/test/Array2.h

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