GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
base-list.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 2002-2025 The Octave Project Developers
4//
5// See the file COPYRIGHT.md in the top-level directory of this
6// distribution or <https://octave.org/copyright/>.
7//
8// This file is part of Octave.
9//
10// Octave is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// Octave is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Octave; see the file COPYING. If not, see
22// <https://www.gnu.org/licenses/>.
23//
24////////////////////////////////////////////////////////////////////////
25
26#if ! defined (octave_base_list_h)
27#define octave_base_list_h 1
28
29#include "octave-config.h"
30
31#warning "using <base-list.h> is discouraged - use <list> instead"
32
33#include <cstdlib>
34
35#include <list>
36
38
39template <typename elt_type>
41{
42public:
43
44 typedef typename std::list<elt_type>::iterator iterator;
45 typedef typename std::list<elt_type>::const_iterator const_iterator;
46
47 typedef typename std::list<elt_type>::reverse_iterator reverse_iterator;
48 typedef typename std::list<elt_type>::const_reverse_iterator
50
51 bool empty () const { return m_lst.empty (); }
52
53 std::size_t size () const { return m_lst.size (); }
54 std::size_t length () const { return size (); }
55
56 iterator erase (iterator pos) { return m_lst.erase (pos); }
57
58 template <typename P>
59 void remove_if (P pred)
60 {
61 m_lst.remove_if (pred);
62 }
63
64 void clear () { m_lst.clear (); }
65
66 iterator begin () { return iterator (m_lst.begin ()); }
67 const_iterator begin () const { return const_iterator (m_lst.begin ()); }
68
69 iterator end () { return iterator (m_lst.end ()); }
70 const_iterator end () const { return const_iterator (m_lst.end ()); }
71
72 reverse_iterator rbegin () { return reverse_iterator (m_lst.rbegin ()); }
74 { return const_reverse_iterator (m_lst.rbegin ()); }
75
78 { return const_reverse_iterator (m_lst.rend ()); }
79
80 elt_type& front () { return m_lst.front (); }
81 elt_type& back () { return m_lst.back (); }
82
83 const elt_type& front () const { return m_lst.front (); }
84 const elt_type& back () const { return m_lst.back (); }
85
86 void push_front (const elt_type& s) { m_lst.push_front (s); }
87 void push_back (const elt_type& s) { m_lst.push_back (s); }
88
89 void pop_front () { m_lst.pop_front (); }
90 void pop_back () { m_lst.pop_back (); }
91
92 // For backward compatibility.
93 void append (const elt_type& s) { m_lst.push_back (s); }
94
95 base_list () = default;
96
97 base_list (const std::list<elt_type>& l) : m_lst (l) { }
98
99 base_list (const base_list& bl) = default;
100
101 base_list& operator = (const base_list& bl) = default;
102
103 virtual ~base_list () = default;
104
105protected:
106
107 std::list<elt_type> m_lst;
108};
109
110OCTAVE_END_NAMESPACE(octave)
111
112#endif
std::size_t length() const
Definition base-list.h:54
std::list< elt_type > m_lst
Definition base-list.h:107
std::list< elt_type >::const_reverse_iterator const_reverse_iterator
Definition base-list.h:49
const elt_type & front() const
Definition base-list.h:83
iterator end()
Definition base-list.h:69
void push_back(const elt_type &s)
Definition base-list.h:87
base_list & operator=(const base_list &bl)=default
const elt_type & back() const
Definition base-list.h:84
virtual ~base_list()=default
base_list(const base_list &bl)=default
void append(const elt_type &s)
Definition base-list.h:93
void pop_front()
Definition base-list.h:89
std::list< elt_type >::const_iterator const_iterator
Definition base-list.h:45
void clear()
Definition base-list.h:64
reverse_iterator rend()
Definition base-list.h:76
const_reverse_iterator rend() const
Definition base-list.h:77
void push_front(const elt_type &s)
Definition base-list.h:86
std::list< elt_type >::reverse_iterator reverse_iterator
Definition base-list.h:47
base_list(const std::list< elt_type > &l)
Definition base-list.h:97
const_iterator begin() const
Definition base-list.h:67
elt_type & front()
Definition base-list.h:80
const_reverse_iterator rbegin() const
Definition base-list.h:73
std::size_t size() const
Definition base-list.h:53
void remove_if(P pred)
Definition base-list.h:59
void pop_back()
Definition base-list.h:90
reverse_iterator rbegin()
Definition base-list.h:72
const_iterator end() const
Definition base-list.h:70
bool empty() const
Definition base-list.h:51
elt_type & back()
Definition base-list.h:81
iterator begin()
Definition base-list.h:66
std::list< elt_type >::iterator iterator
Definition base-list.h:44
base_list()=default
iterator erase(iterator pos)
Definition base-list.h:56
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn