annotate src/oct-map.h @ 4197:40f76ce7a051

[project @ 2002-11-21 18:56:25 by jwe]
author jwe
date Thu, 21 Nov 2002 18:56:25 +0000
parents 5719210fff4c
children 1f04df06e1a6
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
2847
8b262e771614 [project @ 1997-03-27 16:18:26 by jwe]
jwe
parents: 2369
diff changeset
3 Copyright (C) 1996, 1997 John W. Eaton
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
4
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
6
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
7 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
8 under the terms of the GNU General Public License as published by the
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
10 later version.
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
11
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
12 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
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
14 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
15 for more details.
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
16
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, write to the Free
1315
611d403c7f3d [project @ 1995-06-25 19:56:32 by jwe]
jwe
parents: 1297
diff changeset
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
20
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 #if !defined (octave_oct_map_h)
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
24 #define octave_oct_map_h 1
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
25
4192
5719210fff4c [project @ 2002-11-20 16:56:47 by jwe]
jwe
parents: 4066
diff changeset
26 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION)
1297
12ecc2ecf0e3 [project @ 1995-05-01 18:39:43 by jwe]
jwe
parents: 1279
diff changeset
27 #pragma interface
12ecc2ecf0e3 [project @ 1995-05-01 18:39:43 by jwe]
jwe
parents: 1279
diff changeset
28 #endif
12ecc2ecf0e3 [project @ 1995-05-01 18:39:43 by jwe]
jwe
parents: 1279
diff changeset
29
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
30 #include "Map.h"
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
31
3931
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
32 #include "oct-obj.h"
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
33
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1737
diff changeset
34 class string_vector;
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1737
diff changeset
35
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
36 class
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:
3932
2e2e32198722 [project @ 2002-05-07 18:10:44 by jwe]
jwe
parents: 3931
diff changeset
40 Octave_map (void) : map (octave_value_list ()), array_len (0) { }
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
41
3523
b80bbb43a1a9 [project @ 2000-02-02 10:25:52 by jwe]
jwe
parents: 2847
diff changeset
42 Octave_map (const std::string& key, const octave_value& value)
3932
2e2e32198722 [project @ 2002-05-07 18:10:44 by jwe]
jwe
parents: 3931
diff changeset
43 : map (octave_value_list ()), array_len (1)
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
44 {
3931
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
45 map[key] = octave_value_list (value);
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
46 }
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
47
3932
2e2e32198722 [project @ 2002-05-07 18:10:44 by jwe]
jwe
parents: 3931
diff changeset
48 Octave_map (const Octave_map& m)
2e2e32198722 [project @ 2002-05-07 18:10:44 by jwe]
jwe
parents: 3931
diff changeset
49 : map (m.map), array_len (m.array_len) { }
3931
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
50
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
51 Octave_map& operator = (const Octave_map& m)
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
52 {
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
53 if (this != &m)
3932
2e2e32198722 [project @ 2002-05-07 18:10:44 by jwe]
jwe
parents: 3931
diff changeset
54 {
2e2e32198722 [project @ 2002-05-07 18:10:44 by jwe]
jwe
parents: 3931
diff changeset
55 map = m.map;
2e2e32198722 [project @ 2002-05-07 18:10:44 by jwe]
jwe
parents: 3931
diff changeset
56 array_len = m.array_len;
2e2e32198722 [project @ 2002-05-07 18:10:44 by jwe]
jwe
parents: 3931
diff changeset
57 }
3931
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
58 return *this;
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
59 }
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
60
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
61 ~Octave_map (void) { }
1279
f146197d9d37 [project @ 1995-04-26 17:41:20 by jwe]
jwe
parents: 1009
diff changeset
62
3932
2e2e32198722 [project @ 2002-05-07 18:10:44 by jwe]
jwe
parents: 3931
diff changeset
63 // This is the number of keys.
3931
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
64 int length (void) const { return map.length (); }
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
65
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
66 int empty (void) const { return map.empty (); }
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
67
3932
2e2e32198722 [project @ 2002-05-07 18:10:44 by jwe]
jwe
parents: 3931
diff changeset
68 octave_value_list& operator [] (const std::string& key) { return map[key]; }
3931
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
69
4197
40f76ce7a051 [project @ 2002-11-21 18:56:25 by jwe]
jwe
parents: 4192
diff changeset
70 octave_value_list operator [] (const std::string& key) const;
40f76ce7a051 [project @ 2002-11-21 18:56:25 by jwe]
jwe
parents: 4192
diff changeset
71
3931
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
72 void del (const std::string& key) { map.del (key); }
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
73
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
74 Pix first (void) const { return map.first (); }
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
75 void next (Pix& i) const { map.next (i); }
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
76
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
77 std::string key (Pix p) const { return map.key (p); }
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
78
3932
2e2e32198722 [project @ 2002-05-07 18:10:44 by jwe]
jwe
parents: 3931
diff changeset
79 octave_value_list& contents (Pix p) const { return map.contents (p); }
3931
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
80
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
81 Pix seek (const std::string& key) const { return map.seek (key); }
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
82
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
83 int contains (const std::string& key) const { return map.contains (key); }
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
84
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
85 void clear (void) { map.clear (); }
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
86
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3932
diff changeset
87 string_vector keys (void) const;
3931
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
88
3932
2e2e32198722 [project @ 2002-05-07 18:10:44 by jwe]
jwe
parents: 3931
diff changeset
89 int array_length () const;
2e2e32198722 [project @ 2002-05-07 18:10:44 by jwe]
jwe
parents: 3931
diff changeset
90
4197
40f76ce7a051 [project @ 2002-11-21 18:56:25 by jwe]
jwe
parents: 4192
diff changeset
91 Octave_map& assign (const idx_vector& idx, const Octave_map& rhs);
40f76ce7a051 [project @ 2002-11-21 18:56:25 by jwe]
jwe
parents: 4192
diff changeset
92
3932
2e2e32198722 [project @ 2002-05-07 18:10:44 by jwe]
jwe
parents: 3931
diff changeset
93 Octave_map& assign (const idx_vector& idx, const std::string& key,
2e2e32198722 [project @ 2002-05-07 18:10:44 by jwe]
jwe
parents: 3931
diff changeset
94 const octave_value_list& rhs);
2e2e32198722 [project @ 2002-05-07 18:10:44 by jwe]
jwe
parents: 3931
diff changeset
95
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3932
diff changeset
96 Octave_map& assign (const std::string& key, const octave_value_list& rhs);
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3932
diff changeset
97
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3932
diff changeset
98 Octave_map index (idx_vector& idx);
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3932
diff changeset
99
3931
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
100 private:
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
101
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
102 // The map of names to values.
311981a9726d [project @ 2002-05-07 04:49:53 by jwe]
jwe
parents: 3523
diff changeset
103 CHMap<octave_value_list> map;
3932
2e2e32198722 [project @ 2002-05-07 18:10:44 by jwe]
jwe
parents: 3931
diff changeset
104
2e2e32198722 [project @ 2002-05-07 18:10:44 by jwe]
jwe
parents: 3931
diff changeset
105 // The current size of this struct array;
2e2e32198722 [project @ 2002-05-07 18:10:44 by jwe]
jwe
parents: 3931
diff changeset
106 mutable int array_len;
746
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
107 };
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
108
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
109 #endif
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
110
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
111 /*
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
112 ;;; Local Variables: ***
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
113 ;;; mode: C++ ***
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
114 ;;; End: ***
46f6f6a4f5c6 [project @ 1994-09-30 15:05:10 by jwe]
jwe
parents:
diff changeset
115 */