Mercurial > octave
annotate liboctave/util/base-list.h @ 29572:aef11bb4e6d1
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
Files affected: make_int.cc, file-editor-tab.cc, octave-qscintilla.cc,
Cell.cc, Cell.h, call-stack.cc, call-stack.h, cellfun.cc, data.cc,
debug.cc, dlmread.cc, error.cc, event-queue.h, fcn-info.cc,
fcn-info.h, file-io.cc, ft-text-renderer.cc, gl2ps-print.cc,
graphics.cc, graphics.in.h, help.cc, hex2num.cc, input.cc,
latex-text-renderer.cc, load-path.cc, load-save.cc, load-save.h,
ls-hdf5.cc, ls-mat-ascii.cc, ls-mat5.cc, ls-oct-text.cc, mex.cc,
mexproto.h, mxarray.h, oct-map.cc, oct-stream.cc, oct-stream.h,
pager.cc, pager.h, pr-output.cc, regexp.cc, settings.h,
stack-frame.cc, stack-frame.h, strfns.cc, syminfo.cc, symrec.h,
symscope.cc, symscope.h, symtab.cc, sysdep.cc, toplev.cc, utils.cc,
utils.h, variables.cc, __fltk_uigetfile__.cc, __init_fltk__.cc,
audioread.cc, gzip.cc, cdef-class.cc, cdef-manager.cc, cdef-method.cc,
cdef-object.cc, cdef-object.h, ov-base-diag.cc, ov-base-diag.h,
ov-base-mat.cc, ov-base-mat.h, ov-base-scalar.cc, ov-base-scalar.h,
ov-base-sparse.h, ov-base.cc, ov-base.h, ov-cell.cc, ov-cell.h,
ov-ch-mat.cc, ov-class.cc, ov-class.h, ov-classdef.cc,
ov-fcn-handle.cc, ov-java.cc, ov-lazy-idx.h, ov-perm.cc, ov-perm.h,
ov-range.h, ov-str-mat.cc, ov-struct.cc, ov-struct.h, ov-usr-fcn.cc,
ov-usr-fcn.h, ov.cc, ov.h, ovl.cc, octave.cc, bp-table.cc, jit-ir.cc,
jit-ir.h, jit-typeinfo.cc, jit-typeinfo.h, jit-util.h, lex.h, lex.ll,
oct-lvalue.cc, oct-parse.yy, parse.h, profiler.h, pt-eval.cc,
pt-eval.h, pt-jit.cc, pt-jit.h, pt-pr-code.cc, pt-tm-const.cc,
pt-tm-const.h, Array.h, CMatrix.cc, DiagArray2.h, PermMatrix.h,
Sparse.h, dMatrix.cc, fCMatrix.cc, fMatrix.cc, bsxfun-defs.cc,
oct-fftw.cc, oct-fftw.h, randpoisson.cc, sparse-chol.cc,
mx-inlines.cc, file-ops.cc, lo-sysdep.cc, oct-env.cc, oct-time.cc,
action-container.cc, action-container.h, base-list.h, caseless-str.h,
cmd-edit.cc, cmd-hist.cc, data-conv.cc, data-conv.h, f77-fcn.h,
file-info.cc, file-info.h, kpse.cc, kpse.h, lo-cutils.h, lo-hash.h,
lo-regexp.cc, oct-base64.cc, oct-base64.h, oct-binmap.h, oct-glob.cc,
oct-shlib.cc, oct-shlib.h, oct-sort.cc, oct-sparse.h, oct-string.cc,
quit.cc, unwind-prot.h, url-transfer.cc, main.in.cc, mkoctfile.in.cc,
and shared-fcns.h.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 28 Apr 2021 22:57:42 -0400 |
parents | 0a5b15007766 |
children | 796f54d4ddbf |
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 | 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 | 27 #define octave_base_list_h 1 |
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 | 33 #include <list> |
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 | 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 | 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 | 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 | 51 |
29572
aef11bb4e6d1
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
52 std::size_t size (void) const { return m_lst.size (); } |
aef11bb4e6d1
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
53 std::size_t length (void) const { return size (); } |
22333
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 | 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 | 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 | 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 | 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 | 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 | 109 |
110 #endif |