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