ReactOS 0.4.15-dev-7994-gb388cb6
_deque.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2004
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_SPECIALIZED_DEQUE_H
21#define _STLP_SPECIALIZED_DEQUE_H
22
23#ifndef _STLP_POINTERS_SPEC_TOOLS_H
24# include <stl/pointers/_tools.h>
25#endif
26
29
30/*
31 * struct helper to cast deque iterators:
32 */
33template <class _StorageT, class _ValueT>
40
42 iterator tmp;
47 return tmp;
48 }
55 return tmp;
56 }
57
64 return tmp;
65 }
66
73 return tmp;
74 }
75};
76
77#define DEQUE_IMPL _STLP_PTR_IMPL_NAME(deque)
78#if defined (__BORLANDC__) || defined (__DMC__)
79# define typename
80#endif
81
82#if defined (_STLP_USE_TEMPLATE_EXPORT) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
87_STLP_EXPORT_TEMPLATE_CLASS DEQUE_IMPL<void*,allocator<void*> >;
88#endif
89
90#if defined (_STLP_DEBUG)
91# define deque _STLP_NON_DBG_NAME(deque)
92#else
94#endif
95
96template <class _Tp, _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Tp>) >
97class deque
98#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (deque)
99 : public __stlport_class<deque<_Tp, _Alloc> >
100#endif
101{
104 typedef _STLP_PRIV DEQUE_IMPL<_StorageType, _StorageTypeAlloc> _Base;
106
109
110public:
111 typedef _Tp value_type;
113 typedef const value_type* const_pointer;
116 typedef size_t size_type;
123
125
126public: // Basic accessors
127 iterator begin() { return ite_cast_traits::to_value_type_ite(_M_impl.begin()); }
128 iterator end() { return ite_cast_traits::to_value_type_ite(_M_impl.end()); }
129 const_iterator begin() const { return ite_cast_traits::to_value_type_cite(_M_impl.begin()); }
130 const_iterator end() const { return ite_cast_traits::to_value_type_cite(_M_impl.end()); }
131
134 const_reverse_iterator rbegin() const
135 { return const_reverse_iterator(end()); }
136 const_reverse_iterator rend() const
137 { return const_reverse_iterator(begin()); }
138
140 { return cast_traits::to_value_type_ref(_M_impl[__n]); }
142 { return cast_traits::to_value_type_cref(_M_impl[__n]); }
143
145 { return cast_traits::to_value_type_ref(_M_impl.at(__n)); }
147 { return cast_traits::to_value_type_cref(_M_impl.at(__n)); }
148
149 reference front() { return cast_traits::to_value_type_ref(_M_impl.front()); }
150 reference back() { return cast_traits::to_value_type_ref(_M_impl.back()); }
151 const_reference front() const { return cast_traits::to_value_type_cref(_M_impl.front()); }
152 const_reference back() const { return cast_traits::to_value_type_cref(_M_impl.back()); }
153
154 size_type size() const { return _M_impl.size(); }
155 size_type max_size() const { return _M_impl.max_size(); }
156 bool empty() const { return _M_impl.empty(); }
158
159 explicit deque(const allocator_type& __a = allocator_type())
161
162 deque(const _Self& __x) : _M_impl(__x._M_impl) {}
163
164#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
166#else
168#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
169 const allocator_type& __a = allocator_type())
170 : _M_impl(__n, cast_traits::to_storage_type_cref(__val), _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {}
171 // int,long variants may be needed
172#if defined (_STLP_DONT_SUP_DFLT_PARAM)
173 explicit deque(size_type __n) : _M_impl(__n) {}
174#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
175
176#if defined (_STLP_MEMBER_TEMPLATES)
177 template <class _InputIterator>
178 deque(_InputIterator __first, _InputIterator __last,
180#if !defined (_STLP_USE_ITERATOR_WRAPPER)
181 : _M_impl(__first, __last,
183#else
185#endif
186#if defined (_STLP_USE_ITERATOR_WRAPPER)
187 insert(end(), __first, __last);
188#endif
189 }
190
191# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
192 template <class _InputIterator>
193 deque(_InputIterator __first, _InputIterator __last)
194# if !defined (_STLP_USE_ITERATOR_WRAPPER)
195 : _M_impl(__first, __last) {}
196# else
197 { insert(end(), __first, __last); }
198# endif
199# endif
200
201#else
203 const allocator_type& __a = allocator_type() )
204 : _M_impl(cast_traits::to_storage_type_cptr(__first),
205 cast_traits::to_storage_type_cptr(__last),
207
209 const allocator_type& __a = allocator_type() )
210 : _M_impl(ite_cast_traits::to_storage_type_cite(__first),
211 ite_cast_traits::to_storage_type_cite(__last),
213#endif /* _STLP_MEMBER_TEMPLATES */
214
215#if !defined (_STLP_NO_MOVE_SEMANTIC)
218#endif
219
220 _Self& operator= (const _Self& __x) { _M_impl = __x._M_impl; return *this; }
221
222 void swap(_Self& __x) { _M_impl.swap(__x._M_impl); }
223#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
224 void _M_swap_workaround(_Self& __x) { swap(__x); }
225#endif
226
228 _M_impl.assign(__n, cast_traits::to_storage_type_cref(__val));
229 }
230
231#if defined (_STLP_MEMBER_TEMPLATES)
232# if defined (_STLP_USE_ITERATOR_WRAPPER)
233private:
234 template <class _Integer>
235 void _M_assign_dispatch(_Integer __n, _Integer __val,
236 const __true_type&)
237 { _M_impl.assign(__n, __val); }
238
239 template <class _InputIterator>
240 void _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
241 const __false_type&) {
242 _M_impl.assign(_STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__first),
243 _STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__last));
244 }
245
246public:
247# endif
248 template <class _InputIterator>
249 void assign(_InputIterator __first, _InputIterator __last) {
250# if defined (_STLP_USE_ITERATOR_WRAPPER)
251 typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
252 _M_assign_dispatch(__first, __last, _Integral());
253# else
254 _M_impl.assign(__first, __last);
255# endif
256 }
257#else
259 { _M_impl.assign(cast_traits::to_storage_type_cptr(__first),
260 cast_traits::to_storage_type_cptr(__last)); }
262 { _M_impl.assign(ite_cast_traits::to_storage_type_cite(__first),
263 ite_cast_traits::to_storage_type_cite(__last)); }
264#endif /* _STLP_MEMBER_TEMPLATES */
265
266#if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
268#else
269 void push_back(const value_type& __t)
270#endif
271 { _M_impl.push_back(cast_traits::to_storage_type_cref(__t)); }
272
273#if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
275#else
276 void push_front(const value_type& __t)
277#endif
278 { _M_impl.push_front(cast_traits::to_storage_type_cref(__t)); }
279
280# if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
281 void push_back() { _M_impl.push_back(); }
282 void push_front() { _M_impl.push_front(); }
283# endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
284
285 void pop_back() { _M_impl.pop_back(); }
286 void pop_front() { _M_impl.pop_front(); }
287
288#if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
290#else
291 iterator insert(iterator __pos, const value_type& __x)
292#endif
293 { return ite_cast_traits::to_value_type_ite(_M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos),
294 cast_traits::to_storage_type_cref(__x))); }
295
296#if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
298#endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
299
300 void insert(iterator __pos, size_type __n, const value_type& __x)
301 { _M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos), __n, cast_traits::to_storage_type_cref(__x)); }
302
303#if defined (_STLP_MEMBER_TEMPLATES)
304# if defined (_STLP_USE_ITERATOR_WRAPPER)
305private:
306 template <class _Integer>
307 void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val,
308 const __true_type&) {
309 _M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos), __n, __val);
310 }
311
312 template <class _InputIterator>
313 void _M_insert_dispatch(iterator __pos,
314 _InputIterator __first, _InputIterator __last,
315 const __false_type&) {
316 _M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos),
317 _STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__first),
318 _STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__last));
319 }
320
321public:
322# endif
323
324 template <class _InputIterator>
325 void insert(iterator __pos, _InputIterator __first, _InputIterator __last) {
326# if defined (_STLP_USE_ITERATOR_WRAPPER)
327 // Check whether it's an integral type. If so, it's not an iterator.
328 typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
329 _M_insert_dispatch(__pos, __first, __last, _Integral());
330# else
331 _M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos), __first, __last);
332# endif
333 }
334
335#else /* _STLP_MEMBER_TEMPLATES */
336 void insert(iterator __pos,
338 _M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos),
339 cast_traits::to_storage_type_cptr(__first),
340 cast_traits::to_storage_type_cptr(__last));
341 }
342 void insert(iterator __pos,
344 _M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos),
345 ite_cast_traits::to_storage_type_cite(__first),
346 ite_cast_traits::to_storage_type_cite(__last));
347 }
348
349#endif /* _STLP_MEMBER_TEMPLATES */
350
351#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
353#else
354 void resize(size_type __new_size, const value_type& __x)
355#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
356 { _M_impl.resize(__new_size, cast_traits::to_storage_type_cref(__x)); }
357
358#if defined (_STLP_DONT_SUP_DFLT_PARAM)
359 void resize(size_type __new_size) { _M_impl.resize(__new_size); }
360#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
361
363 { return ite_cast_traits::to_value_type_ite(_M_impl.erase(ite_cast_traits::to_storage_type_ite(__pos))); }
364
366 { return ite_cast_traits::to_value_type_ite(_M_impl.erase(ite_cast_traits::to_storage_type_ite(__first),
367 ite_cast_traits::to_storage_type_ite(__last))); }
368 void clear() { _M_impl.clear(); }
369
370private:
372};
373
374#if defined (deque)
375# undef deque
377#endif
378
379#undef DEQUE_IMPL
380#if defined (__BORLANDC__) || defined (__DMC__)
381# undef typename
382#endif
383
385
386#endif /* _STLP_SPECIALIZED_DEQUE_H */
387
388// Local Variables:
389// mode:C++
390// End:
#define reverse_iterator
Definition: _abbrevs.h:34
_STLP_INLINE_LOOP _InputIter __last
Definition: _algo.h:68
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: _deque.h:404
const_iterator end() const
Definition: _deque.h:130
_Base _M_impl
Definition: _deque.h:371
const_reference back() const
Definition: _deque.h:152
void assign(size_type __n, const value_type &__val)
Definition: _deque.h:227
iterator erase(iterator __pos)
Definition: _deque.h:362
iterator end()
Definition: _deque.h:128
size_type max_size() const
Definition: _deque.h:155
reverse_iterator rbegin()
Definition: _deque.h:132
_Self & operator=(const _Self &__x)
Definition: _deque.c:107
_STLP_TYPENAME _STLP_PRIV _StorageType< _Tp >::_Type _StorageType
Definition: _deque.h:102
void pop_front()
Definition: _deque.h:286
void swap(_Self &__x)
Definition: _deque.h:222
void push_back(const value_type &__t=_STLP_DEFAULT_CONSTRUCTED(_Tp))
Definition: _deque.h:668
deque(const_iterator __first, const_iterator __last, const allocator_type &__a=allocator_type())
Definition: _deque.h:208
const_reverse_iterator rend() const
Definition: _deque.h:136
bool empty() const
Definition: _deque.h:156
_Tp value_type
Definition: _deque.h:111
value_type & reference
Definition: _deque.h:114
void push_front(const value_type &__t=_STLP_DEFAULT_CONSTRUCTED(_Tp))
Definition: _deque.h:680
deque(const allocator_type &__a=allocator_type())
Definition: _deque.h:159
reverse_iterator rend()
Definition: _deque.h:133
value_type * pointer
Definition: _deque.h:112
_Base::const_iterator const_iterator
Definition: _deque.h:421
_Alloc_traits< _StorageType, _Alloc >::allocator_type _StorageTypeAlloc
Definition: _deque.h:103
const_reverse_iterator rbegin() const
Definition: _deque.h:134
const_reference front() const
Definition: _deque.h:151
size_type size() const
Definition: _deque.h:154
deque(const_pointer __first, const_pointer __last, const allocator_type &__a=allocator_type())
Definition: _deque.h:202
deque< _Tp, _Alloc > _Self
Definition: _deque.h:105
void resize(size_type __new_size, const value_type &__x=_STLP_DEFAULT_CONSTRUCTED(value_type))
Definition: _deque.h:352
reference back()
Definition: _deque.h:150
iterator erase(iterator __first, iterator __last)
Definition: _deque.h:365
iterator insert(iterator __pos, const value_type &__x=_STLP_DEFAULT_CONSTRUCTED(value_type))
Definition: _deque.h:289
size_t size_type
Definition: _deque.h:116
reference operator[](size_type __n)
Definition: _deque.h:139
const_reference operator[](size_type __n) const
Definition: _deque.h:141
deque(__move_source< _Self > src)
Definition: _deque.h:216
void assign(const_pointer __first, const_pointer __last)
Definition: _deque.h:258
deque(size_type __n, const value_type &__val=_STLP_DEFAULT_CONSTRUCTED(value_type), const allocator_type &__a=allocator_type())
Definition: _deque.h:165
_Base::allocator_type allocator_type
Definition: _deque.h:417
const value_type & const_reference
Definition: _deque.h:115
ptrdiff_t difference_type
Definition: _deque.h:117
_STLP_PRIV _Deque_base< _Tp, _Alloc > _Base
Definition: _deque.h:405
const_reference at(size_type __n) const
Definition: _deque.h:146
allocator_type get_allocator() const
Definition: _deque.h:157
void assign(size_type __n, const _Tp &__val)
Definition: _deque.h:598
void insert(iterator __pos, const_pointer __first, const_pointer __last)
Definition: _deque.h:336
_STLP_PRIV _DequeIteCast< _StorageType, _Tp > ite_cast_traits
Definition: _deque.h:108
const value_type * const_pointer
Definition: _deque.h:113
const_iterator begin() const
Definition: _deque.h:129
void insert(iterator __pos, size_type __n, const value_type &__x)
Definition: _deque.h:300
void push_front(const value_type &__t=_STLP_DEFAULT_CONSTRUCTED(value_type))
Definition: _deque.h:274
void clear()
Definition: _deque.h:368
void push_back(const value_type &__t=_STLP_DEFAULT_CONSTRUCTED(value_type))
Definition: _deque.h:267
void assign(const_iterator __first, const_iterator __last)
Definition: _deque.h:261
_STLP_PRIV _CastTraits< _StorageType, _Tp > cast_traits
Definition: _deque.h:107
deque(const _Self &__x)
Definition: _deque.h:162
reference front()
Definition: _deque.h:149
reference at(size_type __n)
Definition: _deque.h:144
void pop_back()
Definition: _deque.h:285
void resize(size_type __new_size, const value_type &__x=_STLP_DEFAULT_CONSTRUCTED(_Tp))
Definition: _deque.h:811
_STLP_PRIV DEQUE_IMPL< _StorageType, _StorageTypeAlloc > _Base
Definition: _deque.h:104
void insert(iterator __pos, const_iterator __first, const_iterator __last)
Definition: _deque.h:342
random_access_iterator_tag _Iterator_category
Definition: _deque.h:118
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
#define _STLP_MOVE_TO_STD_NAMESPACE
Definition: features.h:525
#define _STLP_TYPENAME
Definition: features.h:612
#define _STLP_ALLOCATOR_TYPE_DFL
Definition: features.h:691
#define _STLP_CLASS_DECLSPEC
Definition: features.h:983
#define _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS
Definition: features.h:747
#define _STLP_EXPORT_TEMPLATE_CLASS
Definition: features.h:987
#define _STLP_EXPORT
Definition: features.h:951
#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
_Rebind_type::other allocator_type
Definition: _alloc.h:201
static storage_type * to_storage_type_ptr(value_type *__ptr)
Definition: _tools.h:417
static value_type * to_value_type_ptr(storage_type *__ptr)
Definition: _tools.h:406
static value_type ** to_value_type_pptr(storage_type **__ptr)
Definition: _tools.h:410
static storage_type ** to_storage_type_pptr(value_type **__ptr)
Definition: _tools.h:421
_Deque_iterator< _ValueT, _Nonconst_traits< _ValueT > > iterator
Definition: _deque.h:35
static iterator to_value_type_ite(storage_iterator const &__ite)
Definition: _deque.h:41
static const_iterator to_value_type_cite(const_storage_iterator const &__ite)
Definition: _deque.h:58
_Deque_iterator< _StorageT, _Nonconst_traits< _StorageT > > storage_iterator
Definition: _deque.h:37
_Deque_iterator< _ValueT, _Const_traits< _ValueT > > const_iterator
Definition: _deque.h:36
static const_storage_iterator to_storage_type_cite(const_iterator const &__ite)
Definition: _deque.h:67
_CastTraits< _StorageT, _ValueT > cast_traits
Definition: _deque.h:39
static storage_iterator to_storage_type_ite(iterator const &__ite)
Definition: _deque.h:49
_Deque_iterator< _StorageT, _Const_traits< _StorageT > > const_storage_iterator
Definition: _deque.h:38
value_type * _M_first
Definition: _deque.h:102
value_type * _M_cur
Definition: _deque.h:101
value_type * _M_last
Definition: _deque.h:103
_Map_pointer _M_node
Definition: _deque.h:104
_QualifiedType _Type
Definition: _tools.h:171
static clock_t begin
Definition: xmllint.c:458
static int insert
Definition: xmllint.c:138