Mercurial > hg > octave-lyh
annotate examples/structdemo.cc @ 9932:6cb30a539481
untabify files in examples directory
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 07 Dec 2009 14:53:20 -0500 |
parents | 4295d634797d |
children | 2204120e38d2 |
rev | line source |
---|---|
6572 | 1 #include <octave/oct.h> |
2 #include <octave/ov-struct.h> | |
3 | |
4 DEFUN_DLD (structdemo, args, , "Struct demo.") | |
5 { | |
6 int nargin = args.length (); | |
7 octave_value retval; | |
8 | |
9 if (nargin != 2) | |
10 print_usage (); | |
11 else | |
12 { | |
13 Octave_map arg0 = args(0).map_value (); | |
14 std::string arg1 = args(1).string_value (); | |
15 | |
16 if (! error_state && arg0.contains (arg1)) | |
17 { | |
18 // The following two lines might be written as | |
19 // octave_value tmp; | |
7081 | 20 // for (Octave_map::iterator p0 = |
9932
6cb30a539481
untabify files in examples directory
John W. Eaton <jwe@octave.org>
parents:
9053
diff
changeset
|
21 // arg0.begin(); |
6572 | 22 // p0 != arg0.end(); p0++ ) |
23 // if (arg0.key (p0) == arg1) | |
24 // { | |
25 // tmp = arg0.contents (p0) (0); | |
26 // break; | |
27 // } | |
28 // though using seek is more concise. | |
29 Octave_map::const_iterator p1 = arg0.seek (arg1); | |
30 octave_value tmp = arg0.contents(p1)(0); | |
31 Octave_map st; | |
32 st.assign ("selected", tmp); | |
33 retval = octave_value (st); | |
34 } | |
35 } | |
36 return retval; | |
37 } | |
38 |