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 |
5307
|
20 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
21 02110-1301, USA. |
1988
|
22 |
|
23 */ |
|
24 |
|
25 #if !defined (octave_Array3_h) |
|
26 #define octave_Array3_h 1 |
|
27 |
|
28 #include <cassert> |
|
29 #include <cstdlib> |
|
30 |
4513
|
31 #include "Array.h" |
1988
|
32 #include "lo-error.h" |
|
33 |
|
34 class idx_vector; |
|
35 |
|
36 // Three dimensional array class. |
|
37 |
|
38 template <class T> |
3585
|
39 class |
4513
|
40 Array3 : public Array<T> |
1988
|
41 { |
|
42 protected: |
|
43 |
5275
|
44 static octave_idx_type get_size (octave_idx_type r, octave_idx_type c, octave_idx_type p) |
4513
|
45 { return Array<T>::get_size (r, c, p); } |
1988
|
46 |
5275
|
47 Array3 (T *d, octave_idx_type r, octave_idx_type c, octave_idx_type p) : Array<T> (d, dim_vector (r, c, p)) { } |
1988
|
48 |
|
49 public: |
|
50 |
4513
|
51 Array3 (void) : Array<T> (dim_vector (0, 0, 0)) { } |
1988
|
52 |
5275
|
53 Array3 (octave_idx_type r, octave_idx_type c, octave_idx_type p) : Array<T> (dim_vector (r, c, p)) { } |
1988
|
54 |
5275
|
55 Array3 (octave_idx_type r, octave_idx_type c, octave_idx_type p, const T& val) |
4513
|
56 : Array<T> (dim_vector (r, c, p), val) { } |
1988
|
57 |
4513
|
58 Array3 (const Array3<T>& a) |
|
59 : Array<T> (a, a.dims ()) { } |
|
60 |
5275
|
61 Array3 (const Array<T>& a, octave_idx_type r, octave_idx_type c, octave_idx_type p) |
4513
|
62 : Array<T> (a, dim_vector (r, c, p)) { } |
1988
|
63 |
|
64 ~Array3 (void) { } |
|
65 |
|
66 Array3<T>& operator = (const Array3<T>& a) |
|
67 { |
4513
|
68 if (this != &a) |
4645
|
69 Array<T>::operator = (a); |
1988
|
70 |
|
71 return *this; |
|
72 } |
|
73 |
5275
|
74 void resize (octave_idx_type r, octave_idx_type c, octave_idx_type p) { this->resize_no_fill (r, c, p); } |
2306
|
75 |
5275
|
76 void resize (octave_idx_type r, octave_idx_type c, octave_idx_type p, const T& val) |
4645
|
77 { this->resize_and_fill (r, c, p, val); } |
1988
|
78 }; |
|
79 |
|
80 #endif |
|
81 |
|
82 /* |
|
83 ;;; Local Variables: *** |
|
84 ;;; mode: C++ *** |
|
85 ;;; End: *** |
|
86 */ |