annotate src/oct-map.h @ 10160:cd96d29c5efa

remove Emacs local-variable settings from source files in src directory
author John W. Eaton <jwe@octave.org>
date Wed, 20 Jan 2010 20:39:26 -0500
parents 17a3df1d992b
children f3b65e1ae355
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
7017
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
3 Copyright (C) 1994, 1995, 1996, 1997, 2000, 2002, 2003, 2004, 2005,
8920
eb63fbe60fab update copyright notices
John W. Eaton <jwe@octave.org>
parents: 8785
diff changeset
4 2006, 2007, 2009 John W. Eaton
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
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
24 #if !defined (octave_oct_map_h)
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"
3931
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
31 #include "oct-obj.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
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
35 class
6109
c68896f193e3 [project @ 2006-10-27 02:16:18 by jwe]
jwe
parents: 6059
diff changeset
36 OCTINTERP_API
3931
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
37 Octave_map
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
38 {
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
39 public:
4219
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4200
diff changeset
40
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4435
diff changeset
41 typedef std::map<std::string, Cell>::iterator iterator;
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4435
diff changeset
42 typedef std::map<std::string, Cell>::const_iterator const_iterator;
4219
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4200
diff changeset
43
5880
84ca47e311b3 [project @ 2006-07-06 22:34:48 by jwe]
jwe
parents: 5781
diff changeset
44 typedef std::list<std::string>::iterator key_list_iterator;
84ca47e311b3 [project @ 2006-07-06 22:34:48 by jwe]
jwe
parents: 5781
diff changeset
45 typedef std::list<std::string>::const_iterator const_key_list_iterator;
84ca47e311b3 [project @ 2006-07-06 22:34:48 by jwe]
jwe
parents: 5781
diff changeset
46
4744
7dcb696159ac [project @ 2004-02-06 05:46:22 by jwe]
jwe
parents: 4675
diff changeset
47 // Warning! You should always use at least two dimensions.
7dcb696159ac [project @ 2004-02-06 05:46:22 by jwe]
jwe
parents: 4675
diff changeset
48
5880
84ca47e311b3 [project @ 2006-07-06 22:34:48 by jwe]
jwe
parents: 5781
diff changeset
49 Octave_map (const dim_vector& dv = dim_vector (0, 0),
6959
47f4f4e88166 [project @ 2007-10-04 20:43:32 by jwe]
jwe
parents: 6946
diff changeset
50 const Cell& key_vals = Cell ());
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
51
4587
7b957b442818 [project @ 2003-11-10 15:50:39 by jwe]
jwe
parents: 4567
diff changeset
52 Octave_map (const std::string& k, const octave_value& value)
5880
84ca47e311b3 [project @ 2006-07-06 22:34:48 by jwe]
jwe
parents: 5781
diff changeset
53 : map (), key_list (), dimensions (1, 1)
84ca47e311b3 [project @ 2006-07-06 22:34:48 by jwe]
jwe
parents: 5781
diff changeset
54 {
84ca47e311b3 [project @ 2006-07-06 22:34:48 by jwe]
jwe
parents: 5781
diff changeset
55 map[k] = value;
84ca47e311b3 [project @ 2006-07-06 22:34:48 by jwe]
jwe
parents: 5781
diff changeset
56 key_list.push_back (k);
84ca47e311b3 [project @ 2006-07-06 22:34:48 by jwe]
jwe
parents: 5781
diff changeset
57 }
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4435
diff changeset
58
8785
70f5a0375afd oct-map.h: fix think-o in previous change
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
59 Octave_map (const string_vector& sv)
70f5a0375afd oct-map.h: fix think-o in previous change
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
60 : map (), key_list (), dimensions (0, 0)
70f5a0375afd oct-map.h: fix think-o in previous change
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
61 {
70f5a0375afd oct-map.h: fix think-o in previous change
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
62 for (octave_idx_type i = 0; i < sv.length (); i++)
70f5a0375afd oct-map.h: fix think-o in previous change
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
63 {
70f5a0375afd oct-map.h: fix think-o in previous change
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
64 std::string k = sv[i];
70f5a0375afd oct-map.h: fix think-o in previous change
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
65 map[k] = Cell ();
70f5a0375afd oct-map.h: fix think-o in previous change
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
66 key_list.push_back (k);
70f5a0375afd oct-map.h: fix think-o in previous change
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
67 }
70f5a0375afd oct-map.h: fix think-o in previous change
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
68 }
70f5a0375afd oct-map.h: fix think-o in previous change
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
69
4587
7b957b442818 [project @ 2003-11-10 15:50:39 by jwe]
jwe
parents: 4567
diff changeset
70 Octave_map (const std::string& k, const Cell& vals)
5880
84ca47e311b3 [project @ 2006-07-06 22:34:48 by jwe]
jwe
parents: 5781
diff changeset
71 : map (), key_list (), dimensions (vals.dims ())
84ca47e311b3 [project @ 2006-07-06 22:34:48 by jwe]
jwe
parents: 5781
diff changeset
72 {
84ca47e311b3 [project @ 2006-07-06 22:34:48 by jwe]
jwe
parents: 5781
diff changeset
73 map[k] = vals;
84ca47e311b3 [project @ 2006-07-06 22:34:48 by jwe]
jwe
parents: 5781
diff changeset
74 key_list.push_back (k);
84ca47e311b3 [project @ 2006-07-06 22:34:48 by jwe]
jwe
parents: 5781
diff changeset
75 }
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
76
4587
7b957b442818 [project @ 2003-11-10 15:50:39 by jwe]
jwe
parents: 4567
diff changeset
77 Octave_map (const std::string& k, const octave_value_list& val_list)
5880
84ca47e311b3 [project @ 2006-07-06 22:34:48 by jwe]
jwe
parents: 5781
diff changeset
78 : map (), key_list (), dimensions (1, val_list.length ())
84ca47e311b3 [project @ 2006-07-06 22:34:48 by jwe]
jwe
parents: 5781
diff changeset
79 {
84ca47e311b3 [project @ 2006-07-06 22:34:48 by jwe]
jwe
parents: 5781
diff changeset
80 map[k] = val_list;
84ca47e311b3 [project @ 2006-07-06 22:34:48 by jwe]
jwe
parents: 5781
diff changeset
81 key_list.push_back (k);
84ca47e311b3 [project @ 2006-07-06 22:34:48 by jwe]
jwe
parents: 5781
diff changeset
82 }
4435
dd7af4fa1942 [project @ 2003-06-23 17:52:36 by jwe]
jwe
parents: 4219
diff changeset
83
5880
84ca47e311b3 [project @ 2006-07-06 22:34:48 by jwe]
jwe
parents: 5781
diff changeset
84 Octave_map (const Octave_map& m)
84ca47e311b3 [project @ 2006-07-06 22:34:48 by jwe]
jwe
parents: 5781
diff changeset
85 : map (m.map), key_list (m.key_list), dimensions (m.dimensions) { }
3931
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
86
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
87 Octave_map& operator = (const Octave_map& m)
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
88 {
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
89 if (this != &m)
3932
2e2e32198722 [project @ 2002-05-07 18:10:44 by jwe]
jwe
parents: 3931
diff changeset
90 {
2e2e32198722 [project @ 2002-05-07 18:10:44 by jwe]
jwe
parents: 3931
diff changeset
91 map = m.map;
5880
84ca47e311b3 [project @ 2006-07-06 22:34:48 by jwe]
jwe
parents: 5781
diff changeset
92 key_list = m.key_list;
4561
e84592dc70b9 [project @ 2003-10-28 21:07:59 by jwe]
jwe
parents: 4513
diff changeset
93 dimensions = m.dimensions;
3932
2e2e32198722 [project @ 2002-05-07 18:10:44 by jwe]
jwe
parents: 3931
diff changeset
94 }
4561
e84592dc70b9 [project @ 2003-10-28 21:07:59 by jwe]
jwe
parents: 4513
diff changeset
95
3931
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
96 return *this;
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
97 }
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
98
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
99 ~Octave_map (void) { }
1279
f146197d9d37 [project @ 1995-04-26 17:41:20 by jwe]
jwe
parents: 1009
diff changeset
100
7046
fbf8576cf399 [project @ 2007-10-22 12:12:20 by dbateman]
dbateman
parents: 7017
diff changeset
101 Octave_map squeeze (void) const;
fbf8576cf399 [project @ 2007-10-22 12:12:20 by dbateman]
dbateman
parents: 7017
diff changeset
102
fbf8576cf399 [project @ 2007-10-22 12:12:20 by dbateman]
dbateman
parents: 7017
diff changeset
103 Octave_map permute (const Array<int>& vec, bool inv = false) const;
fbf8576cf399 [project @ 2007-10-22 12:12:20 by dbateman]
dbateman
parents: 7017
diff changeset
104
3932
2e2e32198722 [project @ 2002-05-07 18:10:44 by jwe]
jwe
parents: 3931
diff changeset
105 // This is the number of keys.
6639
ed74670db09b [project @ 2007-05-21 19:47:22 by jwe]
jwe
parents: 6109
diff changeset
106 octave_idx_type nfields (void) const { return map.size (); }
3931
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
107
4587
7b957b442818 [project @ 2003-11-10 15:50:39 by jwe]
jwe
parents: 4567
diff changeset
108 void del (const std::string& k)
4219
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4200
diff changeset
109 {
4587
7b957b442818 [project @ 2003-11-10 15:50:39 by jwe]
jwe
parents: 4567
diff changeset
110 iterator p = map.find (k);
5881
70b3f8f1a793 [project @ 2006-07-08 03:54:17 by jwe]
jwe
parents: 5880
diff changeset
111
4219
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4200
diff changeset
112 if (p != map.end ())
5881
70b3f8f1a793 [project @ 2006-07-08 03:54:17 by jwe]
jwe
parents: 5880
diff changeset
113 {
70b3f8f1a793 [project @ 2006-07-08 03:54:17 by jwe]
jwe
parents: 5880
diff changeset
114 map.erase (p);
5880
84ca47e311b3 [project @ 2006-07-06 22:34:48 by jwe]
jwe
parents: 5781
diff changeset
115
5882
ef3127d910bc [project @ 2006-07-14 05:30:40 by jwe]
jwe
parents: 5881
diff changeset
116 key_list_iterator q
ef3127d910bc [project @ 2006-07-14 05:30:40 by jwe]
jwe
parents: 5881
diff changeset
117 = std::find (key_list.begin (), key_list.end (), k);
5881
70b3f8f1a793 [project @ 2006-07-08 03:54:17 by jwe]
jwe
parents: 5880
diff changeset
118
70b3f8f1a793 [project @ 2006-07-08 03:54:17 by jwe]
jwe
parents: 5880
diff changeset
119 assert (q != key_list.end ());
70b3f8f1a793 [project @ 2006-07-08 03:54:17 by jwe]
jwe
parents: 5880
diff changeset
120
70b3f8f1a793 [project @ 2006-07-08 03:54:17 by jwe]
jwe
parents: 5880
diff changeset
121 key_list.erase (q);
70b3f8f1a793 [project @ 2006-07-08 03:54:17 by jwe]
jwe
parents: 5880
diff changeset
122 }
4219
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4200
diff changeset
123 }
3931
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
124
4219
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4200
diff changeset
125 iterator begin (void) { return iterator (map.begin ()); }
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4200
diff changeset
126 const_iterator begin (void) const { return const_iterator (map.begin ()); }
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4200
diff changeset
127
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4200
diff changeset
128 iterator end (void) { return iterator (map.end ()); }
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4200
diff changeset
129 const_iterator end (void) const { return const_iterator (map.end ()); }
3931
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
130
4219
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4200
diff changeset
131 std::string key (const_iterator p) const { return p->first; }
3931
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
132
5328
322ab0da00f8 [project @ 2005-05-02 10:48:43 by jwe]
jwe
parents: 5307
diff changeset
133 Cell& contents (const std::string& k);
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4587
diff changeset
134 Cell contents (const std::string& k) const;
3931
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
135
9129
17a3df1d992b avoid double lookups when iterating Octave_map
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
136 Cell& contents (iterator p)
17a3df1d992b avoid double lookups when iterating Octave_map
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
137 { return p->second; }
5328
322ab0da00f8 [project @ 2005-05-02 10:48:43 by jwe]
jwe
parents: 5307
diff changeset
138
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4435
diff changeset
139 Cell contents (const_iterator p) const
9129
17a3df1d992b avoid double lookups when iterating Octave_map
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
140 { return p->second; }
3931
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
141
5156
7c3b22bafedc [project @ 2005-02-22 17:42:15 by jwe]
jwe
parents: 5105
diff changeset
142 int intfield (const std::string& k, int def_val = 0) const;
7c3b22bafedc [project @ 2005-02-22 17:42:15 by jwe]
jwe
parents: 5105
diff changeset
143
7c3b22bafedc [project @ 2005-02-22 17:42:15 by jwe]
jwe
parents: 5105
diff changeset
144 std::string stringfield (const std::string& k,
7c3b22bafedc [project @ 2005-02-22 17:42:15 by jwe]
jwe
parents: 5105
diff changeset
145 const std::string& def_val = std::string ()) const;
7c3b22bafedc [project @ 2005-02-22 17:42:15 by jwe]
jwe
parents: 5105
diff changeset
146
5328
322ab0da00f8 [project @ 2005-05-02 10:48:43 by jwe]
jwe
parents: 5307
diff changeset
147 iterator seek (const std::string& k) { return map.find (k); }
4587
7b957b442818 [project @ 2003-11-10 15:50:39 by jwe]
jwe
parents: 4567
diff changeset
148 const_iterator seek (const std::string& k) const { return map.find (k); }
4219
23d06c9e1edd [project @ 2002-12-06 21:29:17 by jwe]
jwe
parents: 4200
diff changeset
149
4817
6430596f2238 [project @ 2004-03-04 21:13:33 by jwe]
jwe
parents: 4806
diff changeset
150 bool contains (const std::string& k) const
4587
7b957b442818 [project @ 2003-11-10 15:50:39 by jwe]
jwe
parents: 4567
diff changeset
151 { return (seek (k) != map.end ()); }
3931
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
152
5925
fe5cedbf3806 [project @ 2006-08-14 19:08:36 by jwe]
jwe
parents: 5882
diff changeset
153 void clear (void)
fe5cedbf3806 [project @ 2006-08-14 19:08:36 by jwe]
jwe
parents: 5882
diff changeset
154 {
fe5cedbf3806 [project @ 2006-08-14 19:08:36 by jwe]
jwe
parents: 5882
diff changeset
155 map.clear ();
fe5cedbf3806 [project @ 2006-08-14 19:08:36 by jwe]
jwe
parents: 5882
diff changeset
156 key_list.clear ();
fe5cedbf3806 [project @ 2006-08-14 19:08:36 by jwe]
jwe
parents: 5882
diff changeset
157 }
3931
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
158
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3932
diff changeset
159 string_vector keys (void) const;
3931
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
160
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5156
diff changeset
161 octave_idx_type rows (void) const { return dimensions(0); }
4561
e84592dc70b9 [project @ 2003-10-28 21:07:59 by jwe]
jwe
parents: 4513
diff changeset
162
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5156
diff changeset
163 octave_idx_type columns (void) const { return dimensions(1); }
4200
1f04df06e1a6 [project @ 2002-11-22 16:25:49 by jwe]
jwe
parents: 4197
diff changeset
164
4561
e84592dc70b9 [project @ 2003-10-28 21:07:59 by jwe]
jwe
parents: 4513
diff changeset
165 dim_vector dims (void) const { return dimensions; }
4200
1f04df06e1a6 [project @ 2002-11-22 16:25:49 by jwe]
jwe
parents: 4197
diff changeset
166
5435
66ad03c58880 [project @ 2005-08-31 20:41:47 by jwe]
jwe
parents: 5328
diff changeset
167 int ndims (void) const { return dimensions.length (); }
66ad03c58880 [project @ 2005-08-31 20:41:47 by jwe]
jwe
parents: 5328
diff changeset
168
5571
9fc532d861d4 [project @ 2005-12-12 20:45:16 by jwe]
jwe
parents: 5435
diff changeset
169 Octave_map transpose (void) const;
9fc532d861d4 [project @ 2005-12-12 20:45:16 by jwe]
jwe
parents: 5435
diff changeset
170
4567
fc30061d01da [project @ 2003-10-29 20:11:15 by jwe]
jwe
parents: 4561
diff changeset
171 Octave_map reshape (const dim_vector& new_dims) const;
fc30061d01da [project @ 2003-10-29 20:11:15 by jwe]
jwe
parents: 4561
diff changeset
172
5781
faafc2d98b8d [project @ 2006-05-02 19:40:19 by jwe]
jwe
parents: 5731
diff changeset
173 void resize (const dim_vector& dv, bool fill = false);
4936
e63617efbd3f [project @ 2004-08-06 16:18:17 by jwe]
jwe
parents: 4915
diff changeset
174
6639
ed74670db09b [project @ 2007-05-21 19:47:22 by jwe]
jwe
parents: 6109
diff changeset
175 octave_idx_type numel (void) const { return dimensions.numel (); }
3932
2e2e32198722 [project @ 2002-05-07 18:10:44 by jwe]
jwe
parents: 3931
diff changeset
176
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5156
diff changeset
177 Octave_map concat (const Octave_map& rb, const Array<octave_idx_type>& ra_idx);
4806
d3bd9c04147f [project @ 2004-03-02 05:12:32 by jwe]
jwe
parents: 4744
diff changeset
178
5592
61d6cebd243b [project @ 2006-01-12 17:55:22 by dbateman]
dbateman
parents: 5571
diff changeset
179 Octave_map& maybe_delete_elements (const octave_value_list& idx);
61d6cebd243b [project @ 2006-01-12 17:55:22 by dbateman]
dbateman
parents: 5571
diff changeset
180
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4435
diff changeset
181 Octave_map& assign (const octave_value_list& idx, const Octave_map& rhs);
4197
40f76ce7a051 [project @ 2002-11-21 18:56:25 by jwe]
jwe
parents: 4192
diff changeset
182
4587
7b957b442818 [project @ 2003-11-10 15:50:39 by jwe]
jwe
parents: 4567
diff changeset
183 Octave_map& assign (const octave_value_list& idx, const std::string& k,
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4435
diff changeset
184 const Cell& rhs);
3932
2e2e32198722 [project @ 2002-05-07 18:10:44 by jwe]
jwe
parents: 3931
diff changeset
185
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4587
diff changeset
186 Octave_map& assign (const std::string& k, const octave_value& rhs);
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4587
diff changeset
187
4587
7b957b442818 [project @ 2003-11-10 15:50:39 by jwe]
jwe
parents: 4567
diff changeset
188 Octave_map& assign (const std::string& k, const Cell& rhs);
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3932
diff changeset
189
7046
fbf8576cf399 [project @ 2007-10-22 12:12:20 by dbateman]
dbateman
parents: 7017
diff changeset
190 Octave_map index (const octave_value_list& idx,
fbf8576cf399 [project @ 2007-10-22 12:12:20 by dbateman]
dbateman
parents: 7017
diff changeset
191 bool resize_ok = false) const;
fbf8576cf399 [project @ 2007-10-22 12:12:20 by dbateman]
dbateman
parents: 7017
diff changeset
192
3931
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
193 private:
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
194
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
195 // The map of names to values.
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4435
diff changeset
196 std::map<std::string, Cell> map;
3932
2e2e32198722 [project @ 2002-05-07 18:10:44 by jwe]
jwe
parents: 3931
diff changeset
197
5880
84ca47e311b3 [project @ 2006-07-06 22:34:48 by jwe]
jwe
parents: 5781
diff changeset
198 // An extra list of keys, so we can keep track of the order the keys
84ca47e311b3 [project @ 2006-07-06 22:34:48 by jwe]
jwe
parents: 5781
diff changeset
199 // are added for compatibility with you know what.
84ca47e311b3 [project @ 2006-07-06 22:34:48 by jwe]
jwe
parents: 5781
diff changeset
200 std::list<std::string> key_list;
84ca47e311b3 [project @ 2006-07-06 22:34:48 by jwe]
jwe
parents: 5781
diff changeset
201
4561
e84592dc70b9 [project @ 2003-10-28 21:07:59 by jwe]
jwe
parents: 4513
diff changeset
202 // The current size.
e84592dc70b9 [project @ 2003-10-28 21:07:59 by jwe]
jwe
parents: 4513
diff changeset
203 mutable dim_vector dimensions;
5880
84ca47e311b3 [project @ 2006-07-06 22:34:48 by jwe]
jwe
parents: 5781
diff changeset
204
84ca47e311b3 [project @ 2006-07-06 22:34:48 by jwe]
jwe
parents: 5781
diff changeset
205 void maybe_add_to_key_list (const std::string& k)
5925
fe5cedbf3806 [project @ 2006-08-14 19:08:36 by jwe]
jwe
parents: 5882
diff changeset
206 {
fe5cedbf3806 [project @ 2006-08-14 19:08:36 by jwe]
jwe
parents: 5882
diff changeset
207 if (! contains (k))
fe5cedbf3806 [project @ 2006-08-14 19:08:36 by jwe]
jwe
parents: 5882
diff changeset
208 key_list.push_back (k);
fe5cedbf3806 [project @ 2006-08-14 19:08:36 by jwe]
jwe
parents: 5882
diff changeset
209 }
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
210 };
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
211
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
212 #endif