ReactOS 0.4.15-dev-8219-ge8b88cf
_list.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2003
3 * Francois Dumont
4 *
5 * This material is provided "as is", with absolutely no warranty expressed
6 * or implied. Any use is at your own risk.
7 *
8 * Permission to use or copy this software for any purpose is hereby granted
9 * without fee, provided the above notices are retained on all copies.
10 * Permission to modify the code and to distribute modified code is granted,
11 * provided the above notices are retained, and a notice that the code was
12 * modified is included with the above copyright notice.
13 *
14 */
15
16/* NOTE: This is an internal header file, included by other STL headers.
17 * You should not attempt to use it directly.
18 */
19
20#ifndef _STLP_PTR_SPECIALIZED_LIST_H
21#define _STLP_PTR_SPECIALIZED_LIST_H
22
23#ifndef _STLP_POINTERS_SPEC_TOOLS_H
24# include <stl/pointers/_tools.h>
25#endif
26
28
29#define LIST_IMPL _STLP_PTR_IMPL_NAME(list)
30#if defined (__BORLANDC__) || defined (__DMC__)
31# define typename
32#endif
33
34#if defined (_STLP_USE_TEMPLATE_EXPORT) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
35
37
39
41
43
45
48_STLP_EXPORT_TEMPLATE_CLASS LIST_IMPL<void*, allocator<void*> >;
49
51#endif
52
53#if defined (_STLP_DEBUG)
54# define list _STLP_NON_DBG_NAME(list)
56#endif
57
58template <class _Tp, _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Tp>) >
59class list
60#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (list)
61 : public __stlport_class<list<_Tp, _Alloc> >
62#endif
63{
66 typedef _STLP_PRIV LIST_IMPL<_StorageType, _StorageTypeAlloc> _Base;
67 typedef typename _Base::iterator _BaseIte;
68 typedef typename _Base::const_iterator _BaseConstIte;
71
72public:
73 typedef _Tp value_type;
75 typedef const value_type* const_pointer;
78 typedef size_t size_type;
83
86
88
89 allocator_type get_allocator() const
90 { return _STLP_CONVERT_ALLOCATOR(_M_impl.get_allocator(), value_type); }
91
92 explicit list(const allocator_type& __a = allocator_type())
93 : _M_impl(_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {}
94
95#if !defined(_STLP_DONT_SUP_DFLT_PARAM)
97#else
99#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
100 const allocator_type& __a = allocator_type())
101 : _M_impl(__n, cast_traits::to_storage_type_cref(__val),
103
104#if defined(_STLP_DONT_SUP_DFLT_PARAM)
105 explicit list(size_type __n)
106 : _M_impl(__n) {}
107#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
108
109#if defined (_STLP_MEMBER_TEMPLATES)
110 template <class _InputIterator>
111 list(_InputIterator __first, _InputIterator __last,
112 const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
113# if !defined (_STLP_USE_ITERATOR_WRAPPER)
114 : _M_impl(__first, __last, _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {}
115# else
116 : _M_impl(_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {
117 insert(begin(), __first, __last);
118 }
119# endif
120
121# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
122 template <class _InputIterator>
123 list(_InputIterator __first, _InputIterator __last)
124# if !defined (_STLP_USE_WRAPPER_ITERATOR)
125 : _M_impl(__first, __last) {}
126# else
127 { insert(begin(), __first, __last); }
128# endif
129# endif
130
131#else /* _STLP_MEMBER_TEMPLATES */
132
133 list(const value_type *__first, const value_type *__last,
134 const allocator_type& __a = allocator_type())
135 : _M_impl(cast_traits::to_storage_type_cptr(__first),
136 cast_traits::to_storage_type_cptr(__last),
139 const allocator_type& __a = allocator_type())
140 : _M_impl(_BaseConstIte(__first._M_node), _BaseConstIte(__last._M_node),
142
143#endif /* _STLP_MEMBER_TEMPLATES */
144
145 list(const _Self& __x) : _M_impl(__x._M_impl) {}
146
147#if !defined (_STLP_NO_MOVE_SEMANTIC)
149 : _M_impl(__move_source<_Base>(src.get()._M_impl)) {}
150#endif
151
152 iterator begin() { return iterator(_M_impl.begin()._M_node); }
153 const_iterator begin() const { return const_iterator(_M_impl.begin()._M_node); }
154
155 iterator end() { return iterator(_M_impl.end()._M_node); }
156 const_iterator end() const { return const_iterator(_M_impl.end()._M_node); }
157
159 const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
160
162 const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
163
164 bool empty() const { return _M_impl.empty(); }
165 size_type size() const { return _M_impl.size(); }
166 size_type max_size() const { return _M_impl.max_size(); }
167
168 reference front() { return *begin(); }
169 const_reference front() const { return *begin(); }
170 reference back() { return *(--end()); }
171 const_reference back() const { return *(--end()); }
172
173 void swap(_Self &__x) { _M_impl.swap(__x._M_impl); }
174#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
175 void _M_swap_workaround(_Self& __x) { swap(__x); }
176#endif
177 void clear() { _M_impl.clear(); }
178
179#if !defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS)
181#else
183#endif
184 { return iterator(_M_impl.insert(_BaseIte(__pos._M_node),
185 cast_traits::to_storage_type_cref(__x))._M_node); }
186
187#if defined (_STLP_MEMBER_TEMPLATES)
188# if defined (_STLP_USE_ITERATOR_WRAPPER)
189private:
190 template <class _Integer>
191 void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val,
192 const __true_type&)
193 { _M_impl.insert(_BaseIte(__pos._M_node), __n, __val); }
194
195 template <class _InputIterator>
196 void _M_insert_dispatch(iterator __pos,
197 _InputIterator __first, _InputIterator __last,
198 const __false_type&) {
199 _M_impl.insert(_BaseIte(__pos._M_node),
200 _STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__first),
201 _STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__last));
202 }
203
204public:
205# endif
206
207 template <class _InputIterator>
208 void insert(iterator __pos, _InputIterator __first, _InputIterator __last) {
209# if defined (_STLP_USE_ITERATOR_WRAPPER)
210 // Check whether it's an integral type. If so, it's not an iterator.
211 typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
212 _M_insert_dispatch(__pos, __first, __last, _Integral());
213# else
214 _M_impl.insert(_BaseIte(__pos._M_node), __first, __last);
215# endif
216 }
217#else /* _STLP_MEMBER_TEMPLATES */
218 void insert(iterator __pos, const value_type *__first, const value_type *__last)
219 { _M_impl.insert(_BaseIte(__pos._M_node), cast_traits::to_storage_type_cptr(__first),
220 cast_traits::to_storage_type_cptr(__last)); }
222 { _M_impl.insert(_BaseIte(__pos._M_node), _BaseConstIte(__first._M_node), _BaseConstIte(__last._M_node)); }
223#endif /* _STLP_MEMBER_TEMPLATES */
224
225 void insert(iterator __pos, size_type __n, const value_type& __x)
226 { _M_impl.insert(_BaseIte(__pos._M_node), __n, cast_traits::to_storage_type_cref(__x)); }
227
228 void push_front(const value_type& __x) { _M_impl.push_front(cast_traits::to_storage_type_cref(__x)); }
229 void push_back(const value_type& __x) { _M_impl.push_back(cast_traits::to_storage_type_cref(__x)); }
230
231#if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
232 iterator insert(iterator __pos) { return iterator(_M_impl.insert(__pos._M_node)._M_node); }
233 void push_front() { _M_impl.push_front();}
234 void push_back() { _M_impl.push_back();}
235# endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
236
238 { return iterator(_M_impl.erase(_BaseIte(__pos._M_node))._M_node); }
240 { return iterator(_M_impl.erase(_BaseIte(__first._M_node), _BaseIte(__last._M_node))._M_node); }
241
242#if !defined(_STLP_DONT_SUP_DFLT_PARAM)
244#else
245 void resize(size_type __new_size) { _M_impl.resize(__new_size); }
246 void resize(size_type __new_size, const value_type& __x)
247#endif
248 {_M_impl.resize(__new_size, cast_traits::to_storage_type_cref(__x));}
249
250 void pop_front() { _M_impl.pop_front(); }
251 void pop_back() { _M_impl.pop_back(); }
252
253 _Self& operator=(const _Self& __x)
254 { _M_impl = __x._M_impl; return *this; }
256 { _M_impl.assign(__n, cast_traits::to_storage_type_cref(__val)); }
257
258#if defined (_STLP_MEMBER_TEMPLATES)
259# if defined (_STLP_USE_ITERATOR_WRAPPER)
260private:
261 template <class _Integer>
262 void _M_assign_dispatch(_Integer __n, _Integer __val, const __true_type&)
263 { _M_impl.assign(__n, __val); }
264
265 template <class _InputIterator>
266 void _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
267 const __false_type&) {
268 _M_impl.assign(_STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__first),
269 _STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__last));
270 }
271
272public:
273# endif
274
275 template <class _InputIterator>
276 void assign(_InputIterator __first, _InputIterator __last) {
277# if defined (_STLP_USE_ITERATOR_WRAPPER)
278 typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
279 _M_assign_dispatch(__first, __last, _Integral());
280# else
281 _M_impl.assign(__first, __last);
282# endif
283 }
284#else
285 void assign(const value_type *__first, const value_type *__last) {
286 _M_impl.assign(cast_traits::to_storage_type_cptr(__first),
287 cast_traits::to_storage_type_cptr(__last));
288 }
290 { _M_impl.assign(_BaseConstIte(__first._M_node), _BaseConstIte(__last._M_node)); }
291#endif
292
293 void splice(iterator __pos, _Self& __x)
294 { _M_impl.splice(_BaseIte(__pos._M_node), __x._M_impl); }
295 void splice(iterator __pos, _Self& __x, iterator __i)
296 { _M_impl.splice(_BaseIte(__pos._M_node), __x._M_impl, _BaseIte(__i._M_node)); }
297 void splice(iterator __pos, _Self& __x, iterator __first, iterator __last)
298 { _M_impl.splice(_BaseIte(__pos._M_node), __x._M_impl,
299 _BaseIte(__first._M_node), _BaseIte(__last._M_node)); }
300
302 { _M_impl.remove(cast_traits::to_storage_type_cref(__val)); }
303 void unique() { _M_impl.unique(); }
304 void merge(_Self& __x) { _M_impl.merge(__x._M_impl); }
305 void reverse() { _M_impl.reverse(); }
306 void sort() { _M_impl.sort(); }
307
308#if defined (_STLP_MEMBER_TEMPLATES)
309 template <class _Predicate>
310 void remove_if(_Predicate __pred)
312 template <class _BinaryPredicate>
313 void unique(_BinaryPredicate __bin_pred)
315
316 template <class _StrictWeakOrdering>
317 void merge(_Self &__x, _StrictWeakOrdering __comp)
318 { _M_impl.merge(__x._M_impl, _STLP_PRIV _BinaryPredWrapper<_StorageType, _Tp, _StrictWeakOrdering>(__comp)); }
319
320 template <class _StrictWeakOrdering>
321 void sort(_StrictWeakOrdering __comp)
323#endif /* _STLP_MEMBER_TEMPLATES */
324
325private:
327};
328
329#if defined (list)
330# undef list
332#endif
333
334#undef LIST_IMPL
335#if defined (__BORLANDC__) || defined (__DMC__)
336# undef typename
337#endif
338
340
341#endif /* _STLP_PTR_SPECIALIZED_LIST_H */
342
343// Local Variables:
344// mode:C++
345// End:
#define reverse_iterator
Definition: _abbrevs.h:34
_STLP_MOVE_TO_STD_NAMESPACE void sort(_RandomAccessIter __first, _RandomAccessIter __last)
Definition: _algo.c:993
_STLP_MOVE_TO_STD_NAMESPACE _OutputIter merge(_InputIter1 __first1, _InputIter1 __last1, _InputIter2 __first2, _InputIter2 __last2, _OutputIter __result)
Definition: _algo.c:1419
_STLP_INLINE_LOOP _InputIter __last
Definition: _algo.h:68
_STLP_INLINE_LOOP _InputIter _Predicate __pred
Definition: _algo.h:68
_STLP_INLINE_LOOP _ForwardIter remove_if(_ForwardIter __first, _ForwardIter __last, _Predicate __pred)
Definition: _algo.h:278
return __n
Definition: _algo.h:75
_STLP_INLINE_LOOP _InputIter const _Tp & __val
Definition: _algobase.h:656
#define _STLP_CONVERT_ALLOCATOR(__a, _Tp)
Definition: _alloc.h:183
#define _STLP_FORCE_ALLOCATORS(a, y)
Definition: _alloc.h:436
#define _Alloc
Definition: _bvector.h:330
#define _STLP_DEFAULT_CONSTRUCTED(_TTp)
Definition: _construct.h:265
#define _STLP_PRIV
Definition: _dm.h:70
void get(int argc, const char *argv[])
Definition: cmds.c:480
Definition: list.h:37
void pop_front()
Definition: _list.h:250
void insert(iterator __pos, size_type __n, const value_type &__x)
Definition: _list.h:225
void unique()
Definition: _list.h:303
reference back()
Definition: _list.h:170
_STLP_PRIV LIST_IMPL< _StorageType, _StorageTypeAlloc > _Base
Definition: _list.h:66
iterator erase(iterator __first, iterator __last)
Definition: _list.h:239
const_reference back() const
Definition: _list.h:171
const_reference front() const
Definition: _list.h:169
void push_front(const value_type &__x)
Definition: _list.h:228
list< _Tp, _Alloc > _Self
Definition: _list.h:70
value_type & reference
Definition: _list.h:76
_Base::iterator _BaseIte
Definition: _list.h:67
void splice(iterator __pos, _Self &__x)
Definition: _list.h:293
reverse_iterator rend()
Definition: _list.h:161
_STLP_TYPENAME _STLP_PRIV _StorageType< _Tp >::_Type _StorageType
Definition: _list.h:64
void merge(_Self &__x)
Definition: _list.h:304
const value_type * const_pointer
Definition: _list.h:75
iterator erase(iterator __pos)
Definition: _list.h:237
value_type * pointer
Definition: _list.h:74
_Alloc_traits< _StorageType, _Alloc >::allocator_type _StorageTypeAlloc
Definition: _list.h:65
void pop_back()
Definition: _list.h:251
void remove(const_reference __val)
Definition: _list.h:301
list(const _Self &__x)
Definition: _list.h:145
void resize(size_type __new_size, const value_type &__x=_STLP_DEFAULT_CONSTRUCTED(value_type))
Definition: _list.h:243
void swap(_Self &__x)
Definition: _list.h:173
void assign(const_iterator __first, const_iterator __last)
Definition: _list.h:289
_Base _M_impl
Definition: _list.h:326
list(const value_type *__first, const value_type *__last, const allocator_type &__a=allocator_type())
Definition: _list.h:133
_Base::allocator_type allocator_type
Definition: _list.h:271
_Tp value_type
Definition: _list.h:73
iterator insert(iterator __pos, const_reference __x=_STLP_DEFAULT_CONSTRUCTED(value_type))
Definition: _list.h:180
void assign(const value_type *__first, const value_type *__last)
Definition: _list.h:285
void reverse()
Definition: _list.h:305
const_iterator end() const
Definition: _list.h:156
const value_type & const_reference
Definition: _list.h:77
void push_back(const value_type &__x)
Definition: _list.h:229
size_type size() const
Definition: _list.h:165
void sort()
Definition: _list.h:306
size_t size_type
Definition: _list.h:78
_STLP_PRIV _CastTraits< _StorageType, _Tp > cast_traits
Definition: _list.h:69
_STLP_PRIV _List_iterator< _Tp, _Const_traits< _Tp > > const_iterator
Definition: _list.h:276
list(__move_source< _Self > src)
Definition: _list.h:148
ptrdiff_t difference_type
Definition: _list.h:79
const_reverse_iterator rbegin() const
Definition: _list.h:159
iterator begin()
Definition: _list.h:152
void splice(iterator __pos, _Self &__x, iterator __i)
Definition: _list.h:295
size_type max_size() const
Definition: _list.h:166
void assign(size_type __n, const value_type &__val)
Definition: _list.h:255
_STLP_PRIV _List_base< _Tp, _Alloc > _Base
Definition: _list.h:258
const_iterator begin() const
Definition: _list.h:153
iterator end()
Definition: _list.h:155
const_reverse_iterator rend() const
Definition: _list.h:162
list(const_iterator __first, const_iterator __last, const allocator_type &__a=allocator_type())
Definition: _list.h:138
list(size_type __n, const value_type &__val=_STLP_DEFAULT_CONSTRUCTED(value_type), const allocator_type &__a=allocator_type())
Definition: _list.h:96
void insert(iterator __pos, const value_type *__first, const value_type *__last)
Definition: _list.h:218
reverse_iterator rbegin()
Definition: _list.h:158
void insert(iterator __pos, const_iterator __first, const_iterator __last)
Definition: _list.h:221
void clear()
Definition: _list.h:177
reference front()
Definition: _list.h:168
bool empty() const
Definition: _list.h:164
void splice(iterator __pos, _Self &__x, iterator __first, iterator __last)
Definition: _list.h:297
_Base::const_iterator _BaseConstIte
Definition: _list.h:68
_Self & operator=(const _Self &__x)
Definition: _list.h:253
list(const allocator_type &__a=allocator_type())
Definition: _list.h:92
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
#define _STLP_MOVE_TO_STD_NAMESPACE
Definition: features.h:525
#define _STLP_DECLARE_BIDIRECTIONAL_REVERSE_ITERATORS
Definition: features.h:745
#define _STLP_TYPENAME
Definition: features.h:612
#define _STLP_ALLOCATOR_TYPE_DFL
Definition: features.h:691
#define _STLP_EXPORT_TEMPLATE_CLASS
Definition: features.h:987
#define _STLP_BEGIN_NAMESPACE
Definition: features.h:501
#define _STLP_END_NAMESPACE
Definition: features.h:503
#define _STLP_MOVE_TO_PRIV_NAMESPACE
Definition: features.h:524
char typename[32]
Definition: main.c:84
GLuint GLuint end
Definition: gl.h:1545
GLenum src
Definition: glext.h:6340
if(dx< 0)
Definition: linetemp.h:194
#define swap(a, b)
Definition: qsort.c:63
#define list
Definition: rosglue.h:35
_Rebind_type::other allocator_type
Definition: _alloc.h:201
_QualifiedType _Type
Definition: _tools.h:171
static clock_t begin
Definition: xmllint.c:458
static int insert
Definition: xmllint.c:138