annotate libinterp/corefcn/oct-obj.cc @ 19632:76478d2da117

unconditionally disable the octave_allocator class * configure.ac: Delete the --enable-octave-allocator option. * oct-alloc.h: Delete octave_allocator class. Warn if file is included. Unconditionally define macros to be empty. * NEWS: Make note of these changes. * oct-alloc.cc: Delete. * liboctave/util/module.mk (UTIL_SRC): Remove it from the list. * make_int.cc, Cell.h, oct-obj.cc, oct-obj.h, audiodevinfo.cc, ov-base-int.h, ov-base-scalar.h, ov-bool-mat.cc, ov-bool-mat.h, ov-bool-sparse.cc, ov-bool-sparse.h, ov-bool.cc, ov-bool.h, ov-builtin.cc, ov-builtin.h, ov-cell.cc, ov-cell.h, ov-ch-mat.h, ov-class.cc, ov-class.h, ov-classdef.cc, ov-classdef.h, ov-complex.cc, ov-complex.h, ov-cs-list.cc, ov-cs-list.h, ov-cx-diag.cc, ov-cx-diag.h, ov-cx-mat.cc, ov-cx-mat.h, ov-cx-sparse.cc, ov-cx-sparse.h, ov-dld-fcn.cc, ov-dld-fcn.h, ov-fcn-handle.cc, ov-fcn-handle.h, ov-fcn-inline.cc, ov-fcn-inline.h, ov-fcn.cc, ov-fcn.h, ov-float.cc, ov-float.h, ov-flt-complex.cc, ov-flt-complex.h, ov-flt-cx-diag.cc, ov-flt-cx-diag.h, ov-flt-cx-mat.cc, ov-flt-cx-mat.h, ov-flt-re-diag.cc, ov-flt-re-diag.h, ov-flt-re-mat.cc, ov-flt-re-mat.h, ov-int16.cc, ov-int32.cc, ov-int64.cc, ov-int8.cc, ov-intx.h, ov-java.cc, ov-java.h, ov-mex-fcn.cc, ov-mex-fcn.h, ov-perm.cc, ov-perm.h, ov-range.cc, ov-range.h, ov-re-diag.cc, ov-re-diag.h, ov-re-mat.cc, ov-re-mat.h, ov-re-sparse.cc, ov-re-sparse.h, ov-scalar.cc, ov-scalar.h, ov-str-mat.cc, ov-str-mat.h, ov-struct.cc, ov-struct.h, ov-uint16.cc, ov-uint32.cc, ov-uint64.cc, ov-uint8.cc, ov-usr-fcn.cc, ov-usr-fcn.h, ov.cc, ov.h, pt-const.cc, pt-const.h, idx-vector.cc, idx-vector.h: Delete uses of oct-alloc.h and OCTAVE_ALLOCATOR macros.
author John W. Eaton <jwe@octave.org>
date Tue, 20 Jan 2015 13:43:29 -0500
parents 6a71e5030df5
children 4197fc428c7d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
517
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
1 /*
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
2
17744
d63878346099 maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents: 16892
diff changeset
3 Copyright (C) 1994-2013 John W. Eaton
8580
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
4 Copyright (C) 2009 VZLU Prague
517
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
5
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
6 This file is part of Octave.
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
7
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5846
diff changeset
10 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5846
diff changeset
11 option) any later version.
517
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
12
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
16 for more details.
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
17
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5846
diff changeset
19 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5846
diff changeset
20 <http://www.gnu.org/licenses/>.
517
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
21
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
22 */
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
23
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
24 #ifdef HAVE_CONFIG_H
1192
b6360f2d4fa6 [project @ 1995-03-30 21:38:35 by jwe]
jwe
parents: 1009
diff changeset
25 #include <config.h>
517
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
26 #endif
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
27
1968
a2e206524aa0 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents: 1884
diff changeset
28 #include "error.h"
1742
a02f140ed897 [project @ 1996-01-12 11:09:39 by jwe]
jwe
parents: 1352
diff changeset
29 #include "oct-obj.h"
8546
3d8a914c580e improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents: 8523
diff changeset
30 #include "Cell.h"
3d8a914c580e improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents: 8523
diff changeset
31
13917
826f008c829b * oct-obj.h, oct-obj.cc: Use macros to declare and define octave_allocator.
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
32 // We are likely to have a lot of octave_value_list objects to allocate,
826f008c829b * oct-obj.h, oct-obj.cc: Use macros to declare and define octave_allocator.
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
33 // so make the grow_size large.
826f008c829b * oct-obj.h, oct-obj.cc: Use macros to declare and define octave_allocator.
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
34
8580
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
35 octave_value_list::octave_value_list (const std::list<octave_value_list>& lst)
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
36 {
18099
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17744
diff changeset
37 octave_idx_type n = 0;
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17744
diff changeset
38 octave_idx_type nel = 0;
8580
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
39
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
40 // Determine number.
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
41 for (std::list<octave_value_list>::const_iterator p = lst.begin ();
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
42 p != lst.end (); p++)
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
43 {
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
44 n++;
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
45 nel += p->length ();
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
46 }
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
47
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
48 // Optimize single-element case
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
49 if (n == 1)
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
50 data = lst.front ().data;
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
51 else if (nel > 0)
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
52 {
11574
a83bad07f7e3 attempt better backward compatibility for Array resize functions
John W. Eaton <jwe@octave.org>
parents: 11568
diff changeset
53 data.resize (dim_vector (1, nel));
8580
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
54 octave_idx_type k = 0;
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
55 for (std::list<octave_value_list>::const_iterator p = lst.begin ();
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
56 p != lst.end (); p++)
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
57 {
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
58 data.assign (idx_vector (k, k + p->length ()), p->data);
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
59 k += p->length ();
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
60 }
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
61 assert (k == nel);
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
62 }
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
63
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
64 }
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
65
2872
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
66 octave_value_list&
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
67 octave_value_list::prepend (const octave_value& val)
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
68 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
69 octave_idx_type n = length ();
2872
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
70
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
71 resize (n + 1);
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
72
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
73 while (n > 0)
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
74 {
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
75 elem (n) = elem (n - 1);
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
76 n--;
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
77 }
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
78
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
79 elem (0) = val;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
80
2872
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
81 return *this;
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
82 }
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
83
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
84 octave_value_list&
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
85 octave_value_list::append (const octave_value& val)
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
86 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
87 octave_idx_type n = length ();
2872
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
88
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
89 resize (n + 1);
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
90
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
91 elem (n) = val;
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
92
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
93 return *this;
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
94 }
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
95
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
96 octave_value_list&
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
97 octave_value_list::append (const octave_value_list& lst)
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
98 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
99 octave_idx_type len = length ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
100 octave_idx_type lst_len = lst.length ();
2872
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
101
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
102 resize (len + lst_len);
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
103
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
104 for (octave_idx_type i = 0; i < lst_len; i++)
2872
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
105 elem (len + i) = lst (i);
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
106
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
107 return *this;
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
108 }
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
109
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
110 octave_value_list&
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
111 octave_value_list::reverse (void)
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
112 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
113 octave_idx_type n = length ();
2872
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
114
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
115 for (octave_idx_type i = 0; i < n / 2; i++)
2872
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
116 {
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
117 octave_value tmp = elem (i);
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
118 elem (i) = elem (n - i - 1);
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
119 elem (n - i - 1) = tmp;
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
120 }
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
121
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
122 return *this;
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
123 }
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
124
3195
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
125 octave_value_list
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
126 octave_value_list::splice (octave_idx_type offset, octave_idx_type rep_length,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
127 const octave_value_list& lst) const
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
128 {
3195
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
129 octave_value_list retval;
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
130
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
131 octave_idx_type len = length ();
3195
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
132
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
133 if (offset < 0 || offset >= len)
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
134 {
3219
30770ba4457a [project @ 1998-11-13 03:44:31 by jwe]
jwe
parents: 3195
diff changeset
135 if (! (rep_length == 0 && offset == len))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
136 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
137 error ("octave_value_list::splice: invalid OFFSET");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
138 return retval;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
139 }
3195
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
140 }
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
141
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
142 if (rep_length < 0 || rep_length + offset > len)
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
143 {
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
144 error ("octave_value_list::splice: invalid LENGTH");
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
145 return retval;
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
146 }
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
147
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
148 octave_idx_type lst_len = lst.length ();
3195
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
149
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
150 octave_idx_type new_len = len - rep_length + lst_len;
3195
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
151
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
152 retval.resize (new_len);
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
153
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
154 octave_idx_type k = 0;
3195
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
155
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
156 for (octave_idx_type i = 0; i < offset; i++)
3195
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
157 retval(k++) = elem (i);
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
158
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
159 for (octave_idx_type i = 0; i < lst_len; i++)
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
160 retval(k++) = lst (i);
3195
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
161
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
162 for (octave_idx_type i = offset + rep_length; i < len; i++)
3195
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
163 retval(k++) = elem (i);
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
164
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
165 return retval;
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
166 }
7a5a5da64756 [project @ 1998-10-28 22:54:04 by jwe]
jwe
parents: 3180
diff changeset
167
2872
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
168 bool
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
169 octave_value_list::all_strings_p (void) const
1968
a2e206524aa0 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents: 1884
diff changeset
170 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
171 octave_idx_type n = length ();
517
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
172
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
173 for (octave_idx_type i = 0; i < n; i++)
1968
a2e206524aa0 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents: 1884
diff changeset
174 if (! elem(i).is_string ())
5846
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5307
diff changeset
175 return false;
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5307
diff changeset
176
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5307
diff changeset
177 return true;
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5307
diff changeset
178 }
1746
08e778219ef0 [project @ 1996-01-13 08:35:32 by jwe]
jwe
parents: 1742
diff changeset
179
5846
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5307
diff changeset
180 bool
8455
fd11a08a9b31 disallow invalid {}-indexed assigments
Jaroslav Hajek <highegg@gmail.com>
parents: 8437
diff changeset
181 octave_value_list::all_scalars (void) const
fd11a08a9b31 disallow invalid {}-indexed assigments
Jaroslav Hajek <highegg@gmail.com>
parents: 8437
diff changeset
182 {
11568
de5fba8337c5 octave_value_list::all_scalars: test for scalars, not strings
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
183 octave_idx_type n = length ();
8455
fd11a08a9b31 disallow invalid {}-indexed assigments
Jaroslav Hajek <highegg@gmail.com>
parents: 8437
diff changeset
184
11568
de5fba8337c5 octave_value_list::all_scalars: test for scalars, not strings
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
185 for (octave_idx_type i = 0; i < n; i++)
de5fba8337c5 octave_value_list::all_scalars: test for scalars, not strings
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
186 {
de5fba8337c5 octave_value_list::all_scalars: test for scalars, not strings
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
187 dim_vector dv = elem(i).dims ();
de5fba8337c5 octave_value_list::all_scalars: test for scalars, not strings
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
188 if (! dv.all_ones ())
de5fba8337c5 octave_value_list::all_scalars: test for scalars, not strings
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
189 return false;
de5fba8337c5 octave_value_list::all_scalars: test for scalars, not strings
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
190 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
191
11568
de5fba8337c5 octave_value_list::all_scalars: test for scalars, not strings
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
192 return true;
8455
fd11a08a9b31 disallow invalid {}-indexed assigments
Jaroslav Hajek <highegg@gmail.com>
parents: 8437
diff changeset
193 }
fd11a08a9b31 disallow invalid {}-indexed assigments
Jaroslav Hajek <highegg@gmail.com>
parents: 8437
diff changeset
194
fd11a08a9b31 disallow invalid {}-indexed assigments
Jaroslav Hajek <highegg@gmail.com>
parents: 8437
diff changeset
195 bool
10086
76df75b10c80 allow more cells in strfind/strrep + supply a general mechanism
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
196 octave_value_list::any_cell (void) const
76df75b10c80 allow more cells in strfind/strrep + supply a general mechanism
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
197 {
76df75b10c80 allow more cells in strfind/strrep + supply a general mechanism
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
198 octave_idx_type n = length ();
76df75b10c80 allow more cells in strfind/strrep + supply a general mechanism
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
199
76df75b10c80 allow more cells in strfind/strrep + supply a general mechanism
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
200 for (octave_idx_type i = 0; i < n; i++)
10099
29959c705df2 avoid assignment in condition of if statement
John W. Eaton <jwe@octave.org>
parents: 10086
diff changeset
201 if (elem (i).is_cell ())
29959c705df2 avoid assignment in condition of if statement
John W. Eaton <jwe@octave.org>
parents: 10086
diff changeset
202 return true;
29959c705df2 avoid assignment in condition of if statement
John W. Eaton <jwe@octave.org>
parents: 10086
diff changeset
203
29959c705df2 avoid assignment in condition of if statement
John W. Eaton <jwe@octave.org>
parents: 10086
diff changeset
204 return false;
10086
76df75b10c80 allow more cells in strfind/strrep + supply a general mechanism
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
205 }
76df75b10c80 allow more cells in strfind/strrep + supply a general mechanism
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
206
76df75b10c80 allow more cells in strfind/strrep + supply a general mechanism
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
207 bool
5846
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5307
diff changeset
208 octave_value_list::has_magic_colon (void) const
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5307
diff changeset
209 {
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5307
diff changeset
210 octave_idx_type n = length ();
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5307
diff changeset
211
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5307
diff changeset
212 for (octave_idx_type i = 0; i < n; i++)
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5307
diff changeset
213 if (elem(i).is_magic_colon ())
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5307
diff changeset
214 return true;
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5307
diff changeset
215
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5307
diff changeset
216 return false;
517
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
217 }
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
218
1968
a2e206524aa0 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents: 1884
diff changeset
219 string_vector
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 3264
diff changeset
220 octave_value_list::make_argv (const std::string& fcn_name) const
517
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
221 {
1968
a2e206524aa0 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents: 1884
diff changeset
222 string_vector argv;
a2e206524aa0 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents: 1884
diff changeset
223
2872
6285237ed3b9 [project @ 1997-04-19 01:30:58 by jwe]
jwe
parents: 2847
diff changeset
224 if (all_strings_p ())
1968
a2e206524aa0 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents: 1884
diff changeset
225 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
226 octave_idx_type len = length ();
3180
c17387059fd3 [project @ 1998-09-24 18:59:11 by jwe]
jwe
parents: 2970
diff changeset
227
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
228 octave_idx_type total_nr = 0;
3180
c17387059fd3 [project @ 1998-09-24 18:59:11 by jwe]
jwe
parents: 2970
diff changeset
229
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
230 for (octave_idx_type i = 0; i < len; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
231 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
232 // An empty std::string ("") has zero columns and zero rows (a
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
233 // change that was made for Matlab contemptibility.
3264
973c81fbe144 [project @ 1999-09-02 17:47:15 by jwe]
jwe
parents: 3219
diff changeset
234
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
235 octave_idx_type n = elem(i).rows ();
3264
973c81fbe144 [project @ 1999-09-02 17:47:15 by jwe]
jwe
parents: 3219
diff changeset
236
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
237 total_nr += n ? n : 1;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
238 }
3180
c17387059fd3 [project @ 1998-09-24 18:59:11 by jwe]
jwe
parents: 2970
diff changeset
239
8034
f61bd8e0d682 fix default_save_options parsing and allow mixing options with other arguments.
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
240 octave_idx_type k = 0;
f61bd8e0d682 fix default_save_options parsing and allow mixing options with other arguments.
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
241 if (! fcn_name.empty ())
f61bd8e0d682 fix default_save_options parsing and allow mixing options with other arguments.
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
242 {
f61bd8e0d682 fix default_save_options parsing and allow mixing options with other arguments.
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
243 argv.resize (total_nr+1);
f61bd8e0d682 fix default_save_options parsing and allow mixing options with other arguments.
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
244 argv[0] = fcn_name;
f61bd8e0d682 fix default_save_options parsing and allow mixing options with other arguments.
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
245 k = 1;
f61bd8e0d682 fix default_save_options parsing and allow mixing options with other arguments.
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
246 }
f61bd8e0d682 fix default_save_options parsing and allow mixing options with other arguments.
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
247 else
f61bd8e0d682 fix default_save_options parsing and allow mixing options with other arguments.
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
248 argv.resize (total_nr);
3180
c17387059fd3 [project @ 1998-09-24 18:59:11 by jwe]
jwe
parents: 2970
diff changeset
249
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
250 for (octave_idx_type i = 0; i < len; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
251 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
252 octave_idx_type nr = elem(i).rows ();
3180
c17387059fd3 [project @ 1998-09-24 18:59:11 by jwe]
jwe
parents: 2970
diff changeset
253
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
254 if (nr < 2)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
255 argv[k++] = elem(i).string_value ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
256 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
257 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
258 string_vector tmp = elem(i).all_strings ();
3180
c17387059fd3 [project @ 1998-09-24 18:59:11 by jwe]
jwe
parents: 2970
diff changeset
259
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
260 for (octave_idx_type j = 0; j < nr; j++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
261 argv[k++] = tmp[j];
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
262 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
263 }
1968
a2e206524aa0 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents: 1884
diff changeset
264 }
a2e206524aa0 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents: 1884
diff changeset
265 else
a2e206524aa0 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents: 1884
diff changeset
266 error ("%s: expecting all arguments to be strings", fcn_name.c_str ());
517
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
267
1968
a2e206524aa0 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents: 1884
diff changeset
268 return argv;
517
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
269 }
be927cad4cf7 [project @ 1994-07-13 14:38:02 by jwe]
jwe
parents:
diff changeset
270
8150
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8034
diff changeset
271 void
8523
ad3afaaa19c1 implement non-copying contiguous range indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8455
diff changeset
272 octave_value_list::make_storable_values (void)
8150
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8034
diff changeset
273 {
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8034
diff changeset
274 octave_idx_type len = length ();
8579
7e0f36dfefbe implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
275 const Array<octave_value>& cdata = data;
7e0f36dfefbe implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
276
8150
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8034
diff changeset
277 for (octave_idx_type i = 0; i < len; i++)
8579
7e0f36dfefbe implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
278 {
7e0f36dfefbe implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
279 // This is optimized so that we don't force a copy unless necessary.
7e0f36dfefbe implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
280 octave_value tmp = cdata(i).storable_value ();
7e0f36dfefbe implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
281 if (! tmp.is_copy_of (cdata (i)))
7e0f36dfefbe implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
282 data(i) = tmp;
7e0f36dfefbe implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
283 }
8150
283989f2da9b make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 8034
diff changeset
284 }