3353
|
1 /* |
|
2 |
|
3 Copyright (C) 1999 John W. Eaton |
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
4192
|
23 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
3353
|
24 #pragma implementation |
|
25 #endif |
|
26 |
|
27 #ifdef HAVE_CONFIG_H |
|
28 #include <config.h> |
|
29 #endif |
|
30 |
4513
|
31 #include "idx-vector.h" |
|
32 |
3353
|
33 #include "Cell.h" |
|
34 |
4216
|
35 Cell::Cell (const string_vector& sv) |
4513
|
36 : ArrayN<octave_value> () |
4216
|
37 { |
|
38 int n = sv.length (); |
|
39 |
|
40 if (n > 0) |
|
41 { |
4513
|
42 resize_no_fill (n, 1); |
4216
|
43 |
|
44 for (int i = 0; i < n; i++) |
|
45 elem(i,0) = sv[i]; |
|
46 } |
|
47 } |
3354
|
48 |
4513
|
49 Cell |
|
50 Cell::index (const octave_value_list& idx, bool resize_ok) const |
|
51 { |
|
52 Cell retval; |
|
53 |
|
54 int n = idx.length (); |
|
55 |
|
56 switch (n) |
|
57 { |
|
58 case 1: |
|
59 { |
|
60 idx_vector i = idx(0).index_vector (); |
|
61 |
|
62 retval = index (i, resize_ok); |
|
63 } |
|
64 break; |
|
65 |
|
66 case 2: |
|
67 { |
|
68 idx_vector i = idx(0).index_vector (); |
|
69 idx_vector j = idx(1).index_vector (); |
|
70 |
|
71 retval = index (i, j, resize_ok); |
|
72 } |
|
73 break; |
|
74 |
|
75 default: |
|
76 { |
|
77 Array<idx_vector> iv (n); |
|
78 |
|
79 for (int i = 0; i < n; i++) |
|
80 iv(i) = idx(i).index_vector (); |
|
81 |
|
82 retval = index (iv, resize_ok); |
|
83 } |
|
84 break; |
|
85 } |
|
86 |
|
87 return retval; |
|
88 } |
|
89 |
|
90 Cell& |
|
91 Cell::assign (const octave_value_list& idx, const Cell& rhs, |
|
92 const octave_value& fill_val) |
|
93 |
|
94 { |
|
95 for (int i = 0; i < idx.length (); i++) |
|
96 set_index (idx(i).index_vector ()); |
|
97 |
|
98 ::assign (*this, rhs, fill_val); |
|
99 |
|
100 return *this; |
|
101 } |
|
102 |
3353
|
103 /* |
|
104 ;;; Local Variables: *** |
|
105 ;;; mode: C++ *** |
|
106 ;;; End: *** |
|
107 */ |