File: list

package info (click to toggle)
cppreference-doc 20170409-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 259,872 kB
  • sloc: xml: 570,184; python: 1,923; php: 520; makefile: 168; sh: 25; cpp: 9; ansic: 9
file content (271 lines) | stat: -rw-r--r-- 7,772 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
/*  Copyright (C) 2015  Povilas Kanapickas <povilas@radix.lt>

    This file is part of cppreference-doc

    This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
    Unported License. To view a copy of this license, visit
    http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
    Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.

    Permission is granted to copy, distribute and/or modify this document
    under the terms of the GNU Free Documentation License, Version 1.3 or
    any later version published by the Free Software Foundation; with no
    Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
*/

#ifndef CPPREFERENCE_LIST_H
#define CPPREFERENCE_LIST_H

#if CPPREFERENCE_STDVER>= 2011
#include <initializer_list>
#endif

namespace std {

template<class T, class Allocator = allocator<T>>
class list {
public:
    typedef T value_type;
    typedef Allocator allocator_type;
    typedef size_t size_type; // actual type unspecified
    typedef ptrdiff_t difference_type; // actual type not specified
#if CPPREFERENCE_SIMPLIFY_TYPEDEFS
    typedef T& reference;
    typedef const T& const_reference;
    typedef T* pointer;
    typedef const T* const_pointer;
#elif CPPREFERENCE_STDVER <2011
    typedef typename Allocator::reference reference;
    typedef typename Allocator::const_reference const_reference;
    typedef typename Allocator::pointer pointer;
    typedef typename Allocator::const_pointer const_pointer;
#else
    typedef value_type& reference;
    typedef const value_type& const_reference;
    typedef typename std::allocator_traits<Allocator>::pointer pointer;
    typedef typename std::allocator_traits<Allocator>::const_pointer const_pointer;
#endif
    typedef T* iterator; // actual type is unspecified
    typedef const T* const_iterator; // actual type is unspecified
    typedef std::reverse_iterator<iterator> reverse_iterator;
    typedef std::reverse_iterator<const_iterator> const_reverse_iterator;

    // constructor
#if CPPREFERENCE_STDVER <2014
    explicit list(const Allocator& alloc = Allocator());
#else
    list();
    explicit list(const Allocator& alloc);
#endif

#if CPPREFERENCE_STDVER <2011
    explicit list(size_type count,
                  const T& value = T(),
                  const Allocator& alloc = Allocator());
#else
    list(size_type count,
         const T& value,
         const Allocator& alloc = Allocator());

#if CPPREFERENCE_STDVER <2014
    explicit list(size_type n);
#else
    explicit list(size_type n, const Allocator& alloc = Allocator());
#endif

    template<class InputIt>
    list(InputIt first, InputIt last,
         const Allocator& alloc = Allocator());

    list(const list& other);
#if CPPREFERENCE_STDVER>= 2011
    list(const list& other, const Allocator& alloc);
#endif

    list(list&& other);
#if CPPREFERENCE_STDVER>= 2011
    list(list&& other, const Allocator& alloc);

    list(std::initializer_list<T> init,
         const Allocator& alloc = Allocator());
#endif

    ~list();

    list& operator=(const list& other);
#if CPPREFERENCE_STDVER>= 2011
    list& operator=(list&& other);
    list& operator=(initializer_list<T> ilist);
#endif

    void assign(size_type count, const value_type& value);
    template <class InputIt>
    void assign(InputIt first, InputIt last);
#if CPPREFERENCE_STDVER>= 2011
    void assign(std::initializer_list<T> ilist);
#endif

    allocator_type get_allocator() const;

    // element access
    reference       front();
    const_reference front() const;
    reference       back();
    const_reference back() const;

    // iterators
    iterator begin();
    const_iterator begin() const;
    iterator end();
    const_iterator end() const;

    reverse_iterator       rbegin();
    const_reverse_iterator rbegin() const;
    reverse_iterator       rend();
    const_reverse_iterator rend() const;

#if CPPREFERENCE_STDVER>= 2011
    const_iterator         cbegin() const;
    const_iterator         cend() const;
    const_reverse_iterator crbegin() const;
    const_reverse_iterator crend() const;
#endif

    bool empty() const;
    size_type size() const;
    size_type max_size() const;

    // modifiers
    void clear();

#if CPPREFERENCE_STDVER <2011
    iterator insert(iterator pos, const T& value);
    void insert(iterator pos, size_type count, const T& value);
    template<class InputIt>
    void insert(iterator pos, InputIt first, InputIt last);
#else
    iterator insert(const_iterator pos, const T& value);
    iterator insert(const_iterator pos, T&& value);
    iterator insert(const_iterator pos, size_type count, const T& value);
    template<class InputIt>
    iterator insert(const_iterator pos, InputIt first, InputIt last);
    iterator insert(const_iterator pos, std::initializer_list<T> ilist);
#endif

#if CPPREFERENCE_STDVER>= 2011
    template<class... Args>
    iterator emplace(const_iterator pos, Args&& ... args);
#endif

#if CPPREFERENCE_STDVER <2011
    iterator erase(iterator pos);
    iterator erase(iterator first, iterator last);
#else
    iterator erase(const_iterator pos);
    iterator erase(const_iterator first, const_iterator last);
#endif

    void push_back(const T& value);
#if CPPREFERENCE_STDVER>= 2011
    void push_back(T&& value);
#endif

#if CPPREFERENCE_STDVER>= 2011
    template<class... Args>
    void emplace_back(Args&& ... args);
#endif

    void pop_back();

    void push_front(const T& value);
#if CPPREFERENCE_STDVER>= 2011
    void push_front(T&& value);
#endif

#if CPPREFERENCE_STDVER>= 2011
    template<class... Args>
    void emplace_front(Args&& ... args);
#endif

    void pop_front();

#if CPPREFERENCE_STDVER <2011
    void resize(size_type count, T value = T());
#else
    void resize(size_type count);
    void resize(size_type count, const value_type& value);
#endif

    void swap(list& other);

    // operations
    void merge(list& other);

#if CPPREFERENCE_STDVER>= 2011
    void merge(list&& other);
#endif

    template <class Compare>
    void merge(list& other, Compare comp);

#if CPPREFERENCE_STDVER>= 2011
    template <class Compare>
    void merge(list&& other, Compare comp);
#endif

    void splice(const_iterator pos, list& other);
    void splice(const_iterator pos, list& other, const_iterator it);
    void splice(const_iterator pos, list& other,
                const_iterator first, const_iterator last);
#if CPPREFERENCE_STDVER>= 2011
    void splice(const_iterator pos, list&& other);
    void splice(const_iterator pos, list&& other, const_iterator it);
    void splice(const_iterator pos, list&& other,
                const_iterator first, const_iterator last);
#endif

    void remove(const T& value);

    template<class UnaryPredicate>
    void remove_if(UnaryPredicate p);

    void reverse();

    void unique();

    template<class BinaryPredicate>
    void unique(BinaryPredicate p);

    void sort();

    template<class Compare>
    void sort(Compare comp);
};

template<class T, class Alloc>
bool operator==(const list<T, Alloc>& lhs,
                const list<T, Alloc>& rhs);

template<class T, class Alloc>
bool operator!=(const list<T, Alloc>& lhs,
                const list<T, Alloc>& rhs);

template<class T, class Alloc>
bool operator<(const list<T, Alloc>& lhs,
               const list<T, Alloc>& rhs);

template<class T, class Alloc>
bool operator<=(const list<T, Alloc>& lhs,
                const list<T, Alloc>& rhs);

template<class T, class Alloc>
bool operator>(const list<T, Alloc>& lhs,
               const list<T, Alloc>& rhs);

template<class T, class Alloc>
bool operator>=(const list<T, Alloc>& lhs,
                const list<T, Alloc>& rhs);

} // namespace std

#endif // CPPREFERENCE_LIST_H