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