annotate liboctave/util/base-list.h @ 22333:2758af148ced

move base_list and regexp classes to octave namespace * base-list.h (class octave_base_list): Move class to octave namespace and rename to base_list. * lo-regexp.cc, lo-regexp.h (class regexp): Move class to octave namespace. Move global functions to static functions in regexp class. * comment-list.h, regexp.cc, symtab.h, txt-eng.h, variables.cc, pt-arg-list.cc, pt-arg-list.h, pt-array-list.h, pt-classdef.h, pt-decl.h, pt-mat.cc, pt-misc.h, pt-select.h, pt-stmt.h, child-list.h: Update for namespace changes.
author John W. Eaton <jwe@octave.org>
date Wed, 17 Aug 2016 17:57:49 -0400
parents bac0d6f07a3e
children 4caa7b28d183
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4222
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
1 /*
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
2
22323
bac0d6f07a3e maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents: 21589
diff changeset
3 Copyright (C) 2002-2016 John W. Eaton
4222
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
4
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
6
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
8 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: 6842
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6842
diff changeset
10 option) any later version.
4222
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
11
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
15 for more details.
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
16
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
17 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: 6842
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6842
diff changeset
19 <http://www.gnu.org/licenses/>.
4222
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
20
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
21 */
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
22
20791
f7084eae3318 maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents: 19697
diff changeset
23 #if ! defined (octave_base_list_h)
4222
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
24 #define octave_base_list_h 1
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
25
21244
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 21139
diff changeset
26 #include "octave-config.h"
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 21139
diff changeset
27
16237
70f465930546 rearrange class heirarchy for tree_cell and tree_matrix
John W. Eaton <jwe@octave.org>
parents: 15271
diff changeset
28 #include <cstdlib>
70f465930546 rearrange class heirarchy for tree_cell and tree_matrix
John W. Eaton <jwe@octave.org>
parents: 15271
diff changeset
29
4222
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
30 #include <list>
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
31
22333
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
32 namespace octave
4222
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
33 {
22333
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
34 template <typename elt_type>
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
35 class
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
36 base_list
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
37 {
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
38 public:
16627
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16237
diff changeset
39
22333
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
40 typedef typename std::list<elt_type>::iterator iterator;
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
41 typedef typename std::list<elt_type>::const_iterator const_iterator;
4222
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
42
22333
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
43 typedef typename std::list<elt_type>::reverse_iterator reverse_iterator;
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
44 typedef typename std::list<elt_type>::const_reverse_iterator const_reverse_iterator;
4222
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
45
22333
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
46 bool empty (void) const { return lst.empty (); }
4222
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
47
22333
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
48 size_t size (void) const { return lst.size (); }
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
49 size_t length (void) const { return size (); }
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
50
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
51 iterator erase (iterator pos) { return lst.erase (pos); }
17198
81f3b09e3e6e base-list.h: Switch to STL remove_if rather than Sun Compiler workaround.
Rik <rik@octave.org>
parents: 16627
diff changeset
52
22333
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
53 template <typename P>
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
54 void remove_if (P pred)
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
55 {
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
56 lst.remove_if (pred);
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 4222
diff changeset
57
22333
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
58 // FIXME: kluge removed 8/7/13. Eventually this commented
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
59 // code should be deleted.
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
60 //
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
61 // FIXME: this kluge should be removed at some point.
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
62 // We would like to simply call
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
63 //
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
64 // lst.remove_if (pred);
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
65 //
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
66 // but the Sun Studio compiler chokes on that.
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
67 //
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
68 // iterator b = lst.begin ();
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
69 // iterator e = lst.end ();
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
70 // while (b != e)
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
71 // {
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
72 // iterator n = b;
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
73 // n++;
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
74 // if (pred (*b))
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
75 // lst.erase (b);
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
76 // b = n;
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
77 // }
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
78 }
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
79
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
80 void clear (void) { lst.clear (); }
4222
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
81
22333
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
82 iterator begin (void) { return iterator (lst.begin ()); }
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
83 const_iterator begin (void) const { return const_iterator (lst.begin ()); }
4222
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
84
22333
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
85 iterator end (void) { return iterator (lst.end ()); }
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
86 const_iterator end (void) const { return const_iterator (lst.end ()); }
4222
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
87
22333
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
88 reverse_iterator rbegin (void) { return reverse_iterator (lst.rbegin ()); }
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
89 const_reverse_iterator rbegin (void) const
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
90 { return const_reverse_iterator (lst.rbegin ()); }
16627
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16237
diff changeset
91
22333
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
92 reverse_iterator rend (void) { return reverse_iterator (lst.rend ()); }
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
93 const_reverse_iterator rend (void) const
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
94 { return const_reverse_iterator (lst.rend ()); }
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
95
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
96 elt_type& front (void) { return lst.front (); }
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
97 elt_type& back (void) { return lst.back (); }
16627
de91b1621260 adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents: 16237
diff changeset
98
22333
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
99 const elt_type& front (void) const { return lst.front (); }
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
100 const elt_type& back (void) const { return lst.back (); }
4222
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
101
22333
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
102 void push_front (const elt_type& s) { lst.push_front (s); }
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
103 void push_back (const elt_type& s) { lst.push_back (s); }
4222
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
104
22333
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
105 void pop_front (void) { lst.pop_front (); }
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
106 void pop_back (void) { lst.pop_back (); }
8470
5da39b223f61 base-list.h (push_front, pop_front, push_back, pop_back): new functions.
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
107
22333
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
108 // For backward compatibility.
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
109 void append (const elt_type& s) { lst.push_back (s); }
8470
5da39b223f61 base-list.h (push_front, pop_front, push_back, pop_back): new functions.
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
110
22333
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
111 base_list (void) : lst () { }
11515
6dbf9bcce90e more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents: 10313
diff changeset
112
22333
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
113 base_list (const std::list<elt_type>& l) : lst (l) { }
14023
d51b321b5fef move base-list.h from src to liboctave
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
114
22333
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
115 base_list (const base_list& bl) : lst (bl.lst) { }
11515
6dbf9bcce90e more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents: 10313
diff changeset
116
22333
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
117 base_list& operator = (const base_list& bl)
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
118 {
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
119 if (this != &bl)
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
120 {
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
121 lst = bl.lst;
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
122 }
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
123 return *this;
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
124 }
11515
6dbf9bcce90e more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents: 10313
diff changeset
125
22333
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
126 virtual ~base_list (void) { }
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
127
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
128 private:
11515
6dbf9bcce90e more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents: 10313
diff changeset
129
22333
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
130 std::list<elt_type> lst;
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
131 };
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
132 }
4222
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
133
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
134 #endif