annotate libinterp/corefcn/oct-map.h @ 21139:538b57866b90

consistently use "typename" intead of "class" in template declarations * Object.h, QtHandlesUtils.cc, QtHandlesUtils.h, ToolBarButton.cc, ToolBarButton.h, Cell.h, __lin_interpn__.cc, bitfcns.cc, bsxfun.cc, cellfun.cc, data.cc, filter.cc, gcd.cc, graphics.cc, help.cc, kron.cc, lookup.cc, ls-mat5.cc, ls-oct-text.h, lu.cc, max.cc, mgorth.cc, oct-map.cc, oct-map.h, oct-stream.cc, oct-stream.h, octave-link.h, pr-output.cc, profiler.h, schur.cc, sparse-xdiv.cc, sparse-xpow.cc, sqrtm.cc, symtab.h, tril.cc, typecast.cc, variables.cc, xdiv.cc, zfstream.h, __init_fltk__.cc, __magick_read__.cc, chol.cc, qr.cc, ov-base-diag.cc, ov-base-diag.h, ov-base-int.cc, ov-base-int.h, ov-base-mat.cc, ov-base-mat.h, ov-base-scalar.cc, ov-base-scalar.h, ov-base-sparse.cc, ov-base-sparse.h, ov-base.h, ov-classdef.cc, ov-int-traits.h, ov-java.h, ov-usr-fcn.h, ov.cc, ov.h, op-dms-template.cc, oct-parse.in.yy, parse.h, pt-mat.cc, Array-b.cc, Array.cc, Array.h, CDiagMatrix.h, CMatrix.h, CNDArray.h, DiagArray2.cc, DiagArray2.h, MArray.cc, MArray.h, MDiagArray2.cc, MDiagArray2.h, MSparse.cc, MSparse.h, MatrixType.cc, Sparse.cc, Sparse.h, dDiagMatrix.h, dMatrix.h, dNDArray.h, fCDiagMatrix.h, fCMatrix.h, fCNDArray.h, fDiagMatrix.h, fMatrix.h, fNDArray.h, idx-vector.cc, idx-vector.h, intNDArray.cc, intNDArray.h, DET.h, base-aepbal.h, base-lu.cc, base-lu.h, base-qr.cc, base-qr.h, bsxfun-defs.cc, eigs-base.cc, lo-mappers.h, lo-specfun.cc, lo-specfun.h, oct-convn.cc, oct-fftw.cc, oct-norm.cc, sparse-base-chol.cc, sparse-base-chol.h, sparse-base-lu.cc, sparse-base-lu.h, sparse-dmsolve.cc, mx-inlines.cc, action-container.h, base-list.h, lo-traits.h, lo-utils.h, oct-base64.h, oct-binmap.h, oct-cmplx.h, oct-inttypes.cc, oct-inttypes.h, oct-locbuf.h, oct-refcount.h, oct-sort.cc, oct-sort.h: Use "typename" instead of "class" in template declarations.
author John W. Eaton <jwe@octave.org>
date Sun, 24 Jan 2016 13:50:04 -0500
parents 48b2ad5ee801
children 1473547f50f5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
1 /*
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
2
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 18402
diff changeset
3 Copyright (C) 1994-2015 John W. Eaton
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
4 Copyright (C) 2010 VZLU Prague
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
5
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
6 This file is part of Octave.
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
7
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 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: 6959
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: 6959
diff changeset
11 option) any later version.
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
12
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
16 for more details.
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
17
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 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: 6959
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: 6959
diff changeset
20 <http://www.gnu.org/licenses/>.
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
21
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
22 */
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
23
20791
f7084eae3318 maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents: 20232
diff changeset
24 #if ! defined (octave_oct_map_h)
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
25 #define octave_oct_map_h 1
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
26
6059
8fd77759707c [project @ 2006-10-18 02:21:22 by jwe]
jwe
parents: 5925
diff changeset
27 #include <algorithm>
4219
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4200
diff changeset
28 #include <map>
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
29
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4435
diff changeset
30 #include "Cell.h"
20940
48b2ad5ee801 maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents: 20791
diff changeset
31 #include "ovl.h"
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
32
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1737
diff changeset
33 class string_vector;
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1737
diff changeset
34
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
35 // A class holding a map field->index. Supports reference-counting.
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
36 class OCTINTERP_API
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
37 octave_fields
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
38 {
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
39 class fields_rep : public std::map<std::string, octave_idx_type>
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
40 {
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
41 public:
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
42 fields_rep (void) : std::map<std::string, octave_idx_type> (), count (1) { }
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
43 fields_rep (const fields_rep& other)
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
44 : std::map<std::string, octave_idx_type> (other), count (1) { }
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
45
12125
a21a3875ca83 implement a common class for reference counts
Jaroslav Hajek <highegg@gmail.com>
parents: 11586
diff changeset
46 octave_refcount<int> count;
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
47
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
48 private:
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
49 fields_rep& operator = (const fields_rep&); // no assignment!
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
50 };
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
51
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
52 fields_rep *rep;
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
53
11068
b0eec300d3fc avoid SID in octave_fields
Jaroslav Hajek <highegg@gmail.com>
parents: 10766
diff changeset
54 static fields_rep *nil_rep (void)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
55 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
56 static fields_rep nr;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
57 return &nr;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
58 }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
59
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
60 public:
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
61
11068
b0eec300d3fc avoid SID in octave_fields
Jaroslav Hajek <highegg@gmail.com>
parents: 10766
diff changeset
62 octave_fields (void) : rep (nil_rep ()) { rep->count++; }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
63 octave_fields (const string_vector&);
10766
f0304c545588 make map constructors from octave_fields public
Jaroslav Hajek <highegg@gmail.com>
parents: 10764
diff changeset
64 octave_fields (const char * const *);
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
65
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
66 ~octave_fields (void)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
67 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
68 if (--rep->count == 0)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
69 delete rep;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
70 }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
71
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
72 void make_unique (void)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
73 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
74 if (rep->count > 1)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
75 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
76 fields_rep *r = new fields_rep (*rep);
13985
43cc49c7abd1 Use thread-safe atomic reference counting (GCC and MSVC).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 12155
diff changeset
77
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
78 if (--rep->count == 0)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
79 delete rep;
13985
43cc49c7abd1 Use thread-safe atomic reference counting (GCC and MSVC).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 12155
diff changeset
80
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
81 rep = r;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
82 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
83 }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
84
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
85 octave_fields (const octave_fields& o) : rep (o.rep) { rep->count++; }
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
86
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
87 octave_fields&
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
88 operator = (const octave_fields& o)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
89 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
90 o.rep->count++;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
91 if (--rep->count == 0)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
92 delete rep;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
93 rep = o.rep;
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
94
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
95 return *this;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
96 }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
97
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
98 // constant iteration support. non-const iteration intentionally unsupported.
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
99
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
100 typedef std::map<std::string, octave_idx_type>::const_iterator const_iterator;
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
101 typedef const_iterator iterator;
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
102
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
103 const_iterator begin (void) const { return rep->begin (); }
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
104 const_iterator end (void) const { return rep->end (); }
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
105
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
106 std::string key (const_iterator p) const { return p->first; }
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
107 octave_idx_type index (const_iterator p) const { return p->second; }
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
108
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
109 const_iterator seek (const std::string& k) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
110 { return rep->find (k); }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
111
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
112 // high-level methods.
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
113
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
114 // number of fields.
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
115 octave_idx_type nfields (void) const { return rep->size (); }
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
116
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
117 // check whether a field exists.
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
118 bool isfield (const std::string& name) const;
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
119
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
120 // get index of field. return -1 if not exist
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
121 octave_idx_type getfield (const std::string& name) const;
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
122 // get index of field. add if not exist
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
123 octave_idx_type getfield (const std::string& name);
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
124 // remove field and return the index. -1 if didn't exist.
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
125 octave_idx_type rmfield (const std::string& name);
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
126
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
127 // order the fields of this map. creates a permutation
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
128 // used to order the fields.
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
129 void orderfields (Array<octave_idx_type>& perm);
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
130
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
131 // compares two instances for equality up to order of fields.
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
132 // returns a permutation needed to bring the fields of *other*
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
133 // into the order of *this*.
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
134 bool equal_up_to_order (const octave_fields& other,
10760
76079e505f9d optimize cellfun with uniform struct output
Jaroslav Hajek <highegg@gmail.com>
parents: 10757
diff changeset
135 octave_idx_type* perm) const;
76079e505f9d optimize cellfun with uniform struct output
Jaroslav Hajek <highegg@gmail.com>
parents: 10757
diff changeset
136
76079e505f9d optimize cellfun with uniform struct output
Jaroslav Hajek <highegg@gmail.com>
parents: 10757
diff changeset
137 bool equal_up_to_order (const octave_fields& other,
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
138 Array<octave_idx_type>& perm) const;
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
139
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
140 bool is_same (const octave_fields& other) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
141 { return rep == other.rep; }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
142
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
143 // Returns the fields as a vector of strings.
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
144 string_vector fieldnames (void) const;
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
145
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
146 void clear (void)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
147 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
148 *this = octave_fields ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
149 }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
150 };
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
151
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
152
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
153 class OCTINTERP_API
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
154 octave_scalar_map
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
155 {
10766
f0304c545588 make map constructors from octave_fields public
Jaroslav Hajek <highegg@gmail.com>
parents: 10764
diff changeset
156 public:
f0304c545588 make map constructors from octave_fields public
Jaroslav Hajek <highegg@gmail.com>
parents: 10764
diff changeset
157
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
158 octave_scalar_map (const octave_fields& k)
10746
93422177b697 more octave_map compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10744
diff changeset
159 : xkeys (k), xvals (k.nfields ()) { }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
160
10746
93422177b697 more octave_map compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10744
diff changeset
161 octave_scalar_map (void) : xkeys (), xvals () { }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
162
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
163 octave_scalar_map (const string_vector& k)
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 19697
diff changeset
164 : xkeys (k), xvals (k.numel ()) { }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
165
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
166 octave_scalar_map (const octave_scalar_map& m)
10746
93422177b697 more octave_map compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10744
diff changeset
167 : xkeys (m.xkeys), xvals(m.xvals) { }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
168
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
169 octave_scalar_map& operator = (const octave_scalar_map& m)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
170 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
171 xkeys = m.xkeys;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
172 xvals = m.xvals;
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
173
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
174 return *this;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
175 }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
176
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
177 // iteration support. note that both const and non-const iterators are the
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
178 // same. The const/non-const distinction is made by the key & contents method.
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
179 typedef octave_fields::const_iterator const_iterator;
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
180 typedef const_iterator iterator;
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
181
10746
93422177b697 more octave_map compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10744
diff changeset
182 const_iterator begin (void) const { return xkeys.begin (); }
93422177b697 more octave_map compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10744
diff changeset
183 const_iterator end (void) const { return xkeys.end (); }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
184
10746
93422177b697 more octave_map compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10744
diff changeset
185 const_iterator seek (const std::string& k) const { return xkeys.seek (k); }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
186
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
187 std::string key (const_iterator p) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
188 { return xkeys.key (p); }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
189 octave_idx_type index (const_iterator p) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
190 { return xkeys.index (p); }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
191
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
192 const octave_value& contents (const_iterator p) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
193 { return xvals[xkeys.index (p)]; }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
194
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
195 octave_value& contents (iterator p)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
196 { return xvals[xkeys.index (p)]; }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
197
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
198 const octave_value& contents (octave_idx_type i) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
199 { return xvals[i]; }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
200
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
201 octave_value& contents (octave_idx_type i)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
202 { return xvals[i]; }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
203
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
204 // number of fields.
10746
93422177b697 more octave_map compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10744
diff changeset
205 octave_idx_type nfields (void) const { return xkeys.nfields (); }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
206
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
207 // check whether a field exists.
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
208 bool isfield (const std::string& name) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
209 { return xkeys.isfield (name); }
10746
93422177b697 more octave_map compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10744
diff changeset
210
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
211 bool contains (const std::string& name) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
212 { return isfield (name); }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
213
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
214 string_vector fieldnames (void) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
215 { return xkeys.fieldnames (); }
10746
93422177b697 more octave_map compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10744
diff changeset
216
93422177b697 more octave_map compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10744
diff changeset
217 string_vector keys (void) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
218 { return fieldnames (); }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
219
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
220 // get contents of a given field. empty value if not exist.
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
221 octave_value getfield (const std::string& key) const;
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
222
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
223 // set contents of a given field. add if not exist.
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
224 void setfield (const std::string& key, const octave_value& val);
10761
12dfe91e9fab more bkw compatibility for octave_map
Jaroslav Hajek <highegg@gmail.com>
parents: 10760
diff changeset
225 void assign (const std::string& k, const octave_value& val)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
226 { setfield (k, val); }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
227
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
228 // remove a given field. do nothing if not exist.
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
229 void rmfield (const std::string& key);
10746
93422177b697 more octave_map compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10744
diff changeset
230 void del (const std::string& k) { rmfield (k); }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
231
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
232 // return a copy with fields ordered, optionally along with permutation.
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
233 octave_scalar_map orderfields (void) const;
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
234 octave_scalar_map orderfields (Array<octave_idx_type>& perm) const;
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
235 octave_scalar_map orderfields (const octave_scalar_map& other,
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
236 Array<octave_idx_type>& perm) const;
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
237
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
238 // aka getfield/setfield, but the latter returns a reference.
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
239 octave_value contents (const std::string& k) const;
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
240 octave_value& contents (const std::string& k);
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
241
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
242 void clear (void)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
243 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
244 xkeys.clear ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
245 xvals.clear ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
246 }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
247
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
248 friend class octave_map;
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
249
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
250 private:
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
251
10746
93422177b697 more octave_map compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10744
diff changeset
252 octave_fields xkeys;
93422177b697 more octave_map compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10744
diff changeset
253 std::vector<octave_value> xvals;
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
254
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
255 };
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
256
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
257 template <>
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
258 inline octave_scalar_map
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
259 octave_value_extract<octave_scalar_map> (const octave_value& v)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
260 { return v.scalar_map_value (); }
10757
1cc44f3ec814 templated extractors for maps and cells
Jaroslav Hajek <highegg@gmail.com>
parents: 10756
diff changeset
261
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
262 class OCTINTERP_API
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
263 octave_map
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
264 {
10766
f0304c545588 make map constructors from octave_fields public
Jaroslav Hajek <highegg@gmail.com>
parents: 10764
diff changeset
265 public:
f0304c545588 make map constructors from octave_fields public
Jaroslav Hajek <highegg@gmail.com>
parents: 10764
diff changeset
266
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
267 octave_map (const octave_fields& k)
10746
93422177b697 more octave_map compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10744
diff changeset
268 : xkeys (k), xvals (k.nfields ()), dimensions () { }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
269
10753
bee1b1a2e29a yield compatible dims from cell2struct + more fixes. build & tests OK
Jaroslav Hajek <highegg@gmail.com>
parents: 10749
diff changeset
270 octave_map (const dim_vector& dv, const octave_fields& k)
bee1b1a2e29a yield compatible dims from cell2struct + more fixes. build & tests OK
Jaroslav Hajek <highegg@gmail.com>
parents: 10749
diff changeset
271 : xkeys (k), xvals (k.nfields (), Cell (dv)), dimensions (dv) { }
bee1b1a2e29a yield compatible dims from cell2struct + more fixes. build & tests OK
Jaroslav Hajek <highegg@gmail.com>
parents: 10749
diff changeset
272
10756
d808eb829d48 optimize num2cell on structs
Jaroslav Hajek <highegg@gmail.com>
parents: 10755
diff changeset
273 typedef octave_scalar_map element_type;
d808eb829d48 optimize num2cell on structs
Jaroslav Hajek <highegg@gmail.com>
parents: 10755
diff changeset
274
10746
93422177b697 more octave_map compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10744
diff changeset
275 octave_map (void) : xkeys (), xvals (), dimensions () { }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
276
10746
93422177b697 more octave_map compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10744
diff changeset
277 octave_map (const dim_vector& dv) : xkeys (), xvals (), dimensions (dv) { }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
278
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
279 octave_map (const string_vector& k)
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 19697
diff changeset
280 : xkeys (k), xvals (k.numel (), Cell (1, 1)), dimensions (1, 1) { }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
281
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
282 octave_map (const dim_vector& dv, const string_vector& k)
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 19697
diff changeset
283 : xkeys (k), xvals (k.numel (), Cell (dv)), dimensions (dv) { }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
284
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
285 octave_map (const octave_map& m)
10746
93422177b697 more octave_map compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10744
diff changeset
286 : xkeys (m.xkeys), xvals (m.xvals), dimensions (m.dimensions) { }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
287
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
288 octave_map (const octave_scalar_map& m);
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
289
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
290 octave_map& operator = (const octave_map& m)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
291 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
292 xkeys = m.xkeys;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
293 xvals = m.xvals;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
294 dimensions = m.dimensions;
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
295
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
296 return *this;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
297 }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
298
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
299 // iteration support. note that both const and non-const iterators are the
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
300 // same. The const/non-const distinction is made by the key & contents method.
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
301 typedef octave_fields::const_iterator const_iterator;
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
302 typedef const_iterator iterator;
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
303
10746
93422177b697 more octave_map compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10744
diff changeset
304 const_iterator begin (void) const { return xkeys.begin (); }
93422177b697 more octave_map compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10744
diff changeset
305 const_iterator end (void) const { return xkeys.end (); }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
306
10746
93422177b697 more octave_map compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10744
diff changeset
307 const_iterator seek (const std::string& k) const { return xkeys.seek (k); }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
308
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
309 std::string key (const_iterator p) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
310 { return xkeys.key (p); }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
311 octave_idx_type index (const_iterator p) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
312 { return xkeys.index (p); }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
313
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
314 const Cell& contents (const_iterator p) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
315 { return xvals[xkeys.index (p)]; }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
316
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
317 Cell& contents (iterator p)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
318 { return xvals[xkeys.index (p)]; }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
319
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
320 const Cell& contents (octave_idx_type i) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
321 { return xvals[i]; }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
322
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
323 Cell& contents (octave_idx_type i)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
324 { return xvals[i]; }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
325
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
326 // number of fields.
10746
93422177b697 more octave_map compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10744
diff changeset
327 octave_idx_type nfields (void) const { return xkeys.nfields (); }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
328
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
329 // check whether a field exists.
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
330 bool isfield (const std::string& name) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
331 { return xkeys.isfield (name); }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
332
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
333 bool contains (const std::string& name) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
334 { return isfield (name); }
10743
cb3ed842bd30 make the new interface more backward compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10742
diff changeset
335
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
336 string_vector fieldnames (void) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
337 { return xkeys.fieldnames (); }
10746
93422177b697 more octave_map compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10744
diff changeset
338
93422177b697 more octave_map compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10744
diff changeset
339 string_vector keys (void) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
340 { return fieldnames (); }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
341
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
342 // get contents of a given field. empty value if not exist.
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
343 Cell getfield (const std::string& key) const;
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
344
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
345 // set contents of a given field. add if not exist. checks for
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
346 // correct dimensions.
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
347 void setfield (const std::string& key, const Cell& val);
10761
12dfe91e9fab more bkw compatibility for octave_map
Jaroslav Hajek <highegg@gmail.com>
parents: 10760
diff changeset
348 void assign (const std::string& k, const Cell& val)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
349 { setfield (k, val); }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
350
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
351 // remove a given field. do nothing if not exist.
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
352 void rmfield (const std::string& key);
10744
4716e2e17118 fix octave_map::extract_scalar
Jaroslav Hajek <highegg@gmail.com>
parents: 10743
diff changeset
353 void del (const std::string& k) { rmfield (k); }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
354
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
355 // return a copy with fields ordered, optionally along with permutation.
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
356 octave_map orderfields (void) const;
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
357 octave_map orderfields (Array<octave_idx_type>& perm) const;
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
358 octave_map orderfields (const octave_map& other,
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
359 Array<octave_idx_type>& perm) const;
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
360
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
361 // aka getfield/setfield, but the latter returns a reference.
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
362 Cell contents (const std::string& k) const;
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
363 Cell& contents (const std::string& k);
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
364
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
365 void clear (void)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
366 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
367 xkeys.clear ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
368 xvals.clear ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
369 }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
370
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
371 // The Array-like methods.
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
372 octave_idx_type numel (void) const { return dimensions.numel (); }
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
373 octave_idx_type length (void) const { return numel (); }
10764
e141bcb1befd implement map concat optimizations for [] operator
Jaroslav Hajek <highegg@gmail.com>
parents: 10761
diff changeset
374 bool is_empty (void) const { return dimensions.any_zero (); }
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
375
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
376 octave_idx_type rows (void) const { return dimensions(0); }
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
377 octave_idx_type cols (void) const { return dimensions(1); }
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
378 octave_idx_type columns (void) const { return dimensions(1); }
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
379
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
380 // Extract a scalar substructure.
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
381 octave_scalar_map checkelem (octave_idx_type n) const;
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
382 octave_scalar_map checkelem (octave_idx_type i, octave_idx_type j) const;
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
383
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
384 octave_scalar_map
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
385 checkelem (const Array<octave_idx_type>& ra_idx) const;
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
386
10755
6ba7937a6fa4 more array-like methods in octave_map
Jaroslav Hajek <highegg@gmail.com>
parents: 10753
diff changeset
387 octave_scalar_map operator () (octave_idx_type n) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
388 { return checkelem (n); }
10755
6ba7937a6fa4 more array-like methods in octave_map
Jaroslav Hajek <highegg@gmail.com>
parents: 10753
diff changeset
389 octave_scalar_map operator () (octave_idx_type i, octave_idx_type j) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
390 { return checkelem (i, j); }
10755
6ba7937a6fa4 more array-like methods in octave_map
Jaroslav Hajek <highegg@gmail.com>
parents: 10753
diff changeset
391
6ba7937a6fa4 more array-like methods in octave_map
Jaroslav Hajek <highegg@gmail.com>
parents: 10753
diff changeset
392 octave_scalar_map
6ba7937a6fa4 more array-like methods in octave_map
Jaroslav Hajek <highegg@gmail.com>
parents: 10753
diff changeset
393 operator () (const Array<octave_idx_type>& ra_idx) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
394 { return checkelem (ra_idx); }
10755
6ba7937a6fa4 more array-like methods in octave_map
Jaroslav Hajek <highegg@gmail.com>
parents: 10753
diff changeset
395
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
396 octave_map squeeze (void) const;
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
397
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
398 octave_map permute (const Array<int>& vec, bool inv = false) const;
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
399
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
400 dim_vector dims (void) const { return dimensions; }
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
401
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
402 int ndims (void) const { return dimensions.length (); }
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
403
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
404 octave_map transpose (void) const;
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
405
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
406 octave_map reshape (const dim_vector& dv) const;
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
407
10743
cb3ed842bd30 make the new interface more backward compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10742
diff changeset
408 void resize (const dim_vector& dv, bool fill = false);
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
409
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
410 static octave_map
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
411 cat (int dim, octave_idx_type n, const octave_scalar_map *map_list);
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
412
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
413 static octave_map
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
414 cat (int dim, octave_idx_type n, const octave_map *map_list);
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
415
10743
cb3ed842bd30 make the new interface more backward compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10742
diff changeset
416 octave_map index (const idx_vector& i, bool resize_ok = false) const;
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
417
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
418 octave_map index (const idx_vector& i, const idx_vector& j,
10743
cb3ed842bd30 make the new interface more backward compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10742
diff changeset
419 bool resize_ok = false) const;
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
420
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
421 octave_map index (const Array<idx_vector>& ia,
10743
cb3ed842bd30 make the new interface more backward compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10742
diff changeset
422 bool resize_ok = false) const;
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
423
10743
cb3ed842bd30 make the new interface more backward compatible
Jaroslav Hajek <highegg@gmail.com>
parents: 10742
diff changeset
424 octave_map index (const octave_value_list&, bool resize_ok = false) const;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
425
10755
6ba7937a6fa4 more array-like methods in octave_map
Jaroslav Hajek <highegg@gmail.com>
parents: 10753
diff changeset
426 octave_map column (octave_idx_type k) const;
6ba7937a6fa4 more array-like methods in octave_map
Jaroslav Hajek <highegg@gmail.com>
parents: 10753
diff changeset
427 octave_map page (octave_idx_type k) const;
6ba7937a6fa4 more array-like methods in octave_map
Jaroslav Hajek <highegg@gmail.com>
parents: 10753
diff changeset
428
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
429 void assign (const idx_vector& i, const octave_map& rhs);
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
430
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
431 void assign (const idx_vector& i, const idx_vector& j, const octave_map& rhs);
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
432
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
433 void assign (const Array<idx_vector>& ia, const octave_map& rhs);
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
434
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
435 void assign (const octave_value_list&, const octave_map& rhs);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
436
10749
df1a3e0ebbff important fixes for struct rewrite(1)
Jaroslav Hajek <highegg@gmail.com>
parents: 10747
diff changeset
437 void assign (const octave_value_list& idx, const std::string& k,
df1a3e0ebbff important fixes for struct rewrite(1)
Jaroslav Hajek <highegg@gmail.com>
parents: 10747
diff changeset
438 const Cell& rhs);
df1a3e0ebbff important fixes for struct rewrite(1)
Jaroslav Hajek <highegg@gmail.com>
parents: 10747
diff changeset
439
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
440 void delete_elements (const idx_vector& i);
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
441
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
442 void delete_elements (int dim, const idx_vector& i);
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
443
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
444 void delete_elements (const Array<idx_vector>& ia);
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
445
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
446 void delete_elements (const octave_value_list&);
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
447
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
448 octave_map concat (const octave_map& rb,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
449 const Array<octave_idx_type>& ra_idx);
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
450
10760
76079e505f9d optimize cellfun with uniform struct output
Jaroslav Hajek <highegg@gmail.com>
parents: 10757
diff changeset
451 // like checkelem, but no check.
76079e505f9d optimize cellfun with uniform struct output
Jaroslav Hajek <highegg@gmail.com>
parents: 10757
diff changeset
452 octave_scalar_map fast_elem_extract (octave_idx_type n) const;
76079e505f9d optimize cellfun with uniform struct output
Jaroslav Hajek <highegg@gmail.com>
parents: 10757
diff changeset
453
76079e505f9d optimize cellfun with uniform struct output
Jaroslav Hajek <highegg@gmail.com>
parents: 10757
diff changeset
454 // element assignment, no bounds check
76079e505f9d optimize cellfun with uniform struct output
Jaroslav Hajek <highegg@gmail.com>
parents: 10757
diff changeset
455 bool fast_elem_insert (octave_idx_type n, const octave_scalar_map& rhs);
76079e505f9d optimize cellfun with uniform struct output
Jaroslav Hajek <highegg@gmail.com>
parents: 10757
diff changeset
456
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
457 private:
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
458
10746
93422177b697 more octave_map compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10744
diff changeset
459 octave_fields xkeys;
93422177b697 more octave_map compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 10744
diff changeset
460 std::vector<Cell> xvals;
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
461 dim_vector dimensions;
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
462
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
463 void optimize_dimensions (void);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
464 void extract_scalar (octave_scalar_map& dest,
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
465 octave_idx_type index) const;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
466 static void do_cat (int dim, octave_idx_type n,
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
467 const octave_scalar_map *map_list, octave_map& retval);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
468 static void do_cat (int dim, octave_idx_type n,
10742
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
469 const octave_map *map_list, octave_map& retval);
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
470 };
604e13a89c7f initial code for structs rewrite
Jaroslav Hajek <highegg@gmail.com>
parents: 10333
diff changeset
471
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 20940
diff changeset
472 template <>
10757
1cc44f3ec814 templated extractors for maps and cells
Jaroslav Hajek <highegg@gmail.com>
parents: 10756
diff changeset
473 inline octave_map octave_value_extract<octave_map> (const octave_value& v)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
474 { return v.map_value (); }
10757
1cc44f3ec814 templated extractors for maps and cells
Jaroslav Hajek <highegg@gmail.com>
parents: 10756
diff changeset
475
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
476 #endif