annotate liboctave/util/base-list.h @ 29358:0a5b15007766 stable

update Octave Project Developers copyright for the new year In files that have the "Octave Project Developers" copyright notice, update for 2021.
author John W. Eaton <jwe@octave.org>
date Wed, 10 Feb 2021 09:52:15 -0500
parents 863ae57eee69
children aef11bb4e6d1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
29358
0a5b15007766 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 27933
diff changeset
3 // Copyright (C) 2002-2021 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
4222
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
25
20791
f7084eae3318 maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents: 19697
diff changeset
26 #if ! defined (octave_base_list_h)
4222
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
27 #define octave_base_list_h 1
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
28
21244
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 21139
diff changeset
29 #include "octave-config.h"
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 21139
diff changeset
30
16237
70f465930546 rearrange class heirarchy for tree_cell and tree_matrix
John W. Eaton <jwe@octave.org>
parents: 15271
diff changeset
31 #include <cstdlib>
70f465930546 rearrange class heirarchy for tree_cell and tree_matrix
John W. Eaton <jwe@octave.org>
parents: 15271
diff changeset
32
4222
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
33 #include <list>
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
34
22333
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
35 namespace octave
4222
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
36 {
22333
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
37 template <typename elt_type>
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
38 class
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
39 base_list
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
40 {
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
41 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
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>::iterator 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_iterator const_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 typedef typename std::list<elt_type>::reverse_iterator reverse_iterator;
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22333
diff changeset
47 typedef typename std::list<elt_type>::const_reverse_iterator
27933
863ae57eee69 maint: Use Octave coding conventions in liboctave/
Rik <rik@octave.org>
parents: 27923
diff changeset
48 const_reverse_iterator;
4222
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
49
26090
5cff527d0970 make base_list data member protected instead of private
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
50 bool empty (void) const { return m_lst.empty (); }
4222
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
51
26090
5cff527d0970 make base_list data member protected instead of private
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
52 size_t size (void) const { return m_lst.size (); }
22333
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
53 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
54
26090
5cff527d0970 make base_list data member protected instead of private
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
55 iterator erase (iterator pos) { return m_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
56
22333
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
57 template <typename P>
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
58 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
59 {
26090
5cff527d0970 make base_list data member protected instead of private
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
60 m_lst.remove_if (pred);
22333
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
61 }
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
62
26090
5cff527d0970 make base_list data member protected instead of private
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
63 void clear (void) { m_lst.clear (); }
4222
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
64
26090
5cff527d0970 make base_list data member protected instead of private
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
65 iterator begin (void) { return iterator (m_lst.begin ()); }
5cff527d0970 make base_list data member protected instead of private
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
66 const_iterator begin (void) const { return const_iterator (m_lst.begin ()); }
4222
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
67
26090
5cff527d0970 make base_list data member protected instead of private
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
68 iterator end (void) { return iterator (m_lst.end ()); }
5cff527d0970 make base_list data member protected instead of private
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
69 const_iterator end (void) const { return const_iterator (m_lst.end ()); }
4222
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
70
26090
5cff527d0970 make base_list data member protected instead of private
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
71 reverse_iterator rbegin (void) { return reverse_iterator (m_lst.rbegin ()); }
22333
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
72 const_reverse_iterator rbegin (void) const
26090
5cff527d0970 make base_list data member protected instead of private
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
73 { return const_reverse_iterator (m_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
74
26090
5cff527d0970 make base_list data member protected instead of private
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
75 reverse_iterator rend (void) { return reverse_iterator (m_lst.rend ()); }
22333
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
76 const_reverse_iterator rend (void) const
26090
5cff527d0970 make base_list data member protected instead of private
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
77 { return const_reverse_iterator (m_lst.rend ()); }
22333
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
78
26090
5cff527d0970 make base_list data member protected instead of private
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
79 elt_type& front (void) { return m_lst.front (); }
5cff527d0970 make base_list data member protected instead of private
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
80 elt_type& back (void) { return m_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
81
26090
5cff527d0970 make base_list data member protected instead of private
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
82 const elt_type& front (void) const { return m_lst.front (); }
5cff527d0970 make base_list data member protected instead of private
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
83 const elt_type& back (void) const { return m_lst.back (); }
4222
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
84
26090
5cff527d0970 make base_list data member protected instead of private
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
85 void push_front (const elt_type& s) { m_lst.push_front (s); }
5cff527d0970 make base_list data member protected instead of private
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
86 void push_back (const elt_type& s) { m_lst.push_back (s); }
4222
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
87
26090
5cff527d0970 make base_list data member protected instead of private
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
88 void pop_front (void) { m_lst.pop_front (); }
5cff527d0970 make base_list data member protected instead of private
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
89 void pop_back (void) { m_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
90
22333
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
91 // For backward compatibility.
26090
5cff527d0970 make base_list data member protected instead of private
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
92 void append (const elt_type& s) { m_lst.push_back (s); }
11515
6dbf9bcce90e more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents: 10313
diff changeset
93
26090
5cff527d0970 make base_list data member protected instead of private
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
94 base_list (void) = default;
11515
6dbf9bcce90e more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents: 10313
diff changeset
95
26090
5cff527d0970 make base_list data member protected instead of private
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
96 base_list (const std::list<elt_type>& l) : m_lst (l) { }
5cff527d0970 make base_list data member protected instead of private
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
97
5cff527d0970 make base_list data member protected instead of private
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
98 base_list (const base_list& bl) = default;
5cff527d0970 make base_list data member protected instead of private
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
99
5cff527d0970 make base_list data member protected instead of private
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
100 base_list& operator = (const base_list& bl) = default;
11515
6dbf9bcce90e more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents: 10313
diff changeset
101
22868
87e3163f6c87 use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
102 virtual ~base_list (void) = default;
22333
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
103
26090
5cff527d0970 make base_list data member protected instead of private
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
104 protected:
11515
6dbf9bcce90e more data member initialization fixes
John W. Eaton <jwe@octave.org>
parents: 10313
diff changeset
105
26090
5cff527d0970 make base_list data member protected instead of private
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
106 std::list<elt_type> m_lst;
22333
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
107 };
2758af148ced move base_list and regexp classes to octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
108 }
4222
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
109
1363b7e9bf3a [project @ 2002-12-13 14:13:42 by jwe]
jwe
parents:
diff changeset
110 #endif