1993
|
1 // Template array classes |
1988
|
2 /* |
|
3 |
2847
|
4 Copyright (C) 1996, 1997 John W. Eaton |
1988
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
|
10 Free Software Foundation; either version 2, or (at your option) any |
|
11 later version. |
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with Octave; see the file COPYING. If not, write to the Free |
|
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
21 |
|
22 */ |
|
23 |
|
24 #if !defined (octave_Array3_h) |
|
25 #define octave_Array3_h 1 |
|
26 |
4192
|
27 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
1988
|
28 #pragma interface |
|
29 #endif |
|
30 |
|
31 #include <cassert> |
|
32 #include <cstdlib> |
|
33 |
4513
|
34 #include "Array.h" |
1988
|
35 #include "lo-error.h" |
|
36 |
|
37 class idx_vector; |
|
38 |
|
39 // Three dimensional array class. |
|
40 |
|
41 template <class T> |
3585
|
42 class |
4513
|
43 Array3 : public Array<T> |
1988
|
44 { |
|
45 protected: |
|
46 |
4513
|
47 static int get_size (int r, int c, int p) |
|
48 { return Array<T>::get_size (r, c, p); } |
1988
|
49 |
4513
|
50 Array3 (T *d, int r, int c, int p) : Array<T> (d, dim_vector (r, c, p)) { } |
1988
|
51 |
|
52 public: |
|
53 |
4513
|
54 Array3 (void) : Array<T> (dim_vector (0, 0, 0)) { } |
1988
|
55 |
4513
|
56 Array3 (int r, int c, int p) : Array<T> (dim_vector (r, c, p)) { } |
1988
|
57 |
4513
|
58 Array3 (int r, int c, int p, const T& val) |
|
59 : Array<T> (dim_vector (r, c, p), val) { } |
1988
|
60 |
4513
|
61 Array3 (const Array3<T>& a) |
|
62 : Array<T> (a, a.dims ()) { } |
|
63 |
|
64 Array3 (const Array<T>& a, int r, int c, int p) |
|
65 : Array<T> (a, dim_vector (r, c, p)) { } |
1988
|
66 |
|
67 ~Array3 (void) { } |
|
68 |
|
69 Array3<T>& operator = (const Array3<T>& a) |
|
70 { |
4513
|
71 if (this != &a) |
1988
|
72 { |
|
73 Array<T>::operator = (a); |
4513
|
74 |
|
75 dimensions = a.dimensions; |
1988
|
76 } |
|
77 |
|
78 return *this; |
|
79 } |
|
80 |
4513
|
81 void resize (int r, int c, int p) { resize_no_fill (r, c, p); } |
2306
|
82 |
4513
|
83 void resize (int r, int c, int p, const T& val) |
|
84 { resize_and_fill (r, c, p, val); } |
1988
|
85 }; |
|
86 |
|
87 #endif |
|
88 |
|
89 /* |
|
90 ;;; Local Variables: *** |
|
91 ;;; mode: C++ *** |
|
92 ;;; End: *** |
|
93 */ |