ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

_deque.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2004
00003  * Francois Dumont
00004  *
00005  * This material is provided "as is", with absolutely no warranty expressed
00006  * or implied. Any use is at your own risk.
00007  *
00008  * Permission to use or copy this software for any purpose is hereby granted
00009  * without fee, provided the above notices are retained on all copies.
00010  * Permission to modify the code and to distribute modified code is granted,
00011  * provided the above notices are retained, and a notice that the code was
00012  * modified is included with the above copyright notice.
00013  *
00014  */
00015 
00016 /* NOTE: This is an internal header file, included by other STL headers.
00017  *   You should not attempt to use it directly.
00018  */
00019 
00020 #ifndef _STLP_SPECIALIZED_DEQUE_H
00021 #define _STLP_SPECIALIZED_DEQUE_H
00022 
00023 #ifndef _STLP_POINTERS_SPEC_TOOLS_H
00024 #  include <stl/pointers/_tools.h>
00025 #endif
00026 
00027 _STLP_BEGIN_NAMESPACE
00028 _STLP_MOVE_TO_PRIV_NAMESPACE
00029 
00030 /*
00031  * struct helper to cast deque iterators:
00032  */
00033 template <class _StorageT, class _ValueT>
00034 struct _DequeIteCast {
00035   typedef _Deque_iterator<_ValueT, _Nonconst_traits<_ValueT> > iterator;
00036   typedef _Deque_iterator<_ValueT, _Const_traits<_ValueT> >    const_iterator;
00037   typedef _Deque_iterator<_StorageT, _Nonconst_traits<_StorageT> > storage_iterator;
00038   typedef _Deque_iterator<_StorageT, _Const_traits<_StorageT> > const_storage_iterator;
00039   typedef _CastTraits<_StorageT, _ValueT> cast_traits;
00040 
00041   static iterator to_value_type_ite (storage_iterator const& __ite) {
00042     iterator tmp;
00043     tmp._M_cur = cast_traits::to_value_type_ptr(__ite._M_cur);
00044     tmp._M_first = cast_traits::to_value_type_ptr(__ite._M_first);
00045     tmp._M_last = cast_traits::to_value_type_ptr(__ite._M_last);
00046     tmp._M_node = cast_traits::to_value_type_pptr(__ite._M_node);
00047     return tmp;
00048   }
00049   static storage_iterator to_storage_type_ite (iterator const& __ite) {
00050     storage_iterator tmp;
00051     tmp._M_cur = cast_traits::to_storage_type_ptr(__ite._M_cur);
00052     tmp._M_first = cast_traits::to_storage_type_ptr(__ite._M_first);
00053     tmp._M_last = cast_traits::to_storage_type_ptr(__ite._M_last);
00054     tmp._M_node = cast_traits::to_storage_type_pptr(__ite._M_node);
00055     return tmp;
00056   }
00057 
00058   static const_iterator to_value_type_cite (const_storage_iterator const& __ite) {
00059     const_iterator tmp;
00060     tmp._M_cur = cast_traits::to_value_type_ptr(__ite._M_cur);
00061     tmp._M_first = cast_traits::to_value_type_ptr(__ite._M_first);
00062     tmp._M_last = cast_traits::to_value_type_ptr(__ite._M_last);
00063     tmp._M_node = cast_traits::to_value_type_pptr(__ite._M_node);
00064     return tmp;
00065   }
00066 
00067   static const_storage_iterator to_storage_type_cite (const_iterator const& __ite) {
00068     const_storage_iterator tmp;
00069     tmp._M_cur = cast_traits::to_storage_type_ptr(__ite._M_cur);
00070     tmp._M_first = cast_traits::to_storage_type_ptr(__ite._M_first);
00071     tmp._M_last = cast_traits::to_storage_type_ptr(__ite._M_last);
00072     tmp._M_node = cast_traits::to_storage_type_pptr(__ite._M_node);
00073     return tmp;
00074   }
00075 };
00076 
00077 #define DEQUE_IMPL _STLP_PTR_IMPL_NAME(deque)
00078 #if defined (__BORLANDC__) || defined (__DMC__)
00079 #  define typename
00080 #endif
00081 
00082 #if defined (_STLP_USE_TEMPLATE_EXPORT) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
00083 _STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<size_t, void*,  allocator<void*> >;
00084 _STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<void***, void**,  allocator<void**> >;
00085 _STLP_EXPORT template struct _STLP_CLASS_DECLSPEC _Deque_iterator<void*, _Nonconst_traits<void*> >;
00086 _STLP_EXPORT_TEMPLATE_CLASS _Deque_base<void*,allocator<void*> >;
00087 _STLP_EXPORT_TEMPLATE_CLASS DEQUE_IMPL<void*,allocator<void*> >;
00088 #endif
00089 
00090 #if defined (_STLP_DEBUG)
00091 #  define deque _STLP_NON_DBG_NAME(deque)
00092 #else
00093 _STLP_MOVE_TO_STD_NAMESPACE
00094 #endif
00095 
00096 template <class _Tp, _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Tp>) >
00097 class deque
00098 #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (deque)
00099             : public __stlport_class<deque<_Tp, _Alloc> >
00100 #endif
00101 {
00102   typedef _STLP_TYPENAME _STLP_PRIV _StorageType<_Tp>::_Type _StorageType;
00103   typedef typename _Alloc_traits<_StorageType, _Alloc>::allocator_type _StorageTypeAlloc;
00104   typedef _STLP_PRIV DEQUE_IMPL<_StorageType, _StorageTypeAlloc> _Base;
00105   typedef deque<_Tp, _Alloc> _Self;
00106 
00107   typedef _STLP_PRIV _CastTraits<_StorageType, _Tp> cast_traits;
00108   typedef _STLP_PRIV _DequeIteCast<_StorageType, _Tp> ite_cast_traits;
00109 
00110 public:
00111   typedef _Tp value_type;
00112   typedef value_type* pointer;
00113   typedef const value_type* const_pointer;
00114   typedef value_type& reference;
00115   typedef const value_type& const_reference;
00116   typedef size_t size_type;
00117   typedef ptrdiff_t difference_type;
00118   typedef random_access_iterator_tag _Iterator_category;
00119   _STLP_FORCE_ALLOCATORS(value_type, _Alloc)
00120   typedef typename _Alloc_traits<value_type, _Alloc>::allocator_type allocator_type;
00121   typedef _STLP_PRIV _Deque_iterator<value_type, _Nonconst_traits<value_type> > iterator;
00122   typedef _STLP_PRIV _Deque_iterator<value_type, _Const_traits<value_type> >    const_iterator;
00123 
00124   _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS;
00125 
00126 public:                         // Basic accessors
00127   iterator begin() { return ite_cast_traits::to_value_type_ite(_M_impl.begin()); }
00128   iterator end()   { return ite_cast_traits::to_value_type_ite(_M_impl.end()); }
00129   const_iterator begin() const { return ite_cast_traits::to_value_type_cite(_M_impl.begin()); }
00130   const_iterator end() const   { return ite_cast_traits::to_value_type_cite(_M_impl.end()); }
00131 
00132   reverse_iterator rbegin() { return reverse_iterator(end()); }
00133   reverse_iterator rend()   { return reverse_iterator(begin()); }
00134   const_reverse_iterator rbegin() const
00135   { return const_reverse_iterator(end()); }
00136   const_reverse_iterator rend() const
00137   { return const_reverse_iterator(begin()); }
00138 
00139   reference operator[](size_type __n)
00140   { return cast_traits::to_value_type_ref(_M_impl[__n]); }
00141   const_reference operator[](size_type __n) const
00142   { return cast_traits::to_value_type_cref(_M_impl[__n]); }
00143 
00144   reference at(size_type __n)
00145   { return cast_traits::to_value_type_ref(_M_impl.at(__n)); }
00146   const_reference at(size_type __n) const
00147   { return cast_traits::to_value_type_cref(_M_impl.at(__n)); }
00148 
00149   reference front() { return cast_traits::to_value_type_ref(_M_impl.front()); }
00150   reference back()  { return cast_traits::to_value_type_ref(_M_impl.back()); }
00151   const_reference front() const { return cast_traits::to_value_type_cref(_M_impl.front()); }
00152   const_reference back() const  { return cast_traits::to_value_type_cref(_M_impl.back()); }
00153 
00154   size_type size() const     { return _M_impl.size(); }
00155   size_type max_size() const { return _M_impl.max_size(); }
00156   bool empty() const         { return _M_impl.empty(); }
00157   allocator_type get_allocator() const { return _STLP_CONVERT_ALLOCATOR(_M_impl.get_allocator(), value_type); }
00158 
00159   explicit deque(const allocator_type& __a = allocator_type())
00160     : _M_impl(_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {}
00161 
00162   deque(const _Self& __x) : _M_impl(__x._M_impl) {}
00163 
00164 #if !defined (_STLP_DONT_SUP_DFLT_PARAM)
00165   explicit deque(size_type __n, const value_type& __val = _STLP_DEFAULT_CONSTRUCTED(value_type),
00166 #else
00167   deque(size_type __n, const value_type& __val,
00168 #endif /*_STLP_DONT_SUP_DFLT_PARAM*/
00169         const allocator_type& __a = allocator_type())
00170     : _M_impl(__n, cast_traits::to_storage_type_cref(__val), _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {}
00171   // int,long variants may be needed
00172 #if defined (_STLP_DONT_SUP_DFLT_PARAM)
00173   explicit deque(size_type __n) : _M_impl(__n) {}
00174 #endif /*_STLP_DONT_SUP_DFLT_PARAM*/
00175 
00176 #if defined (_STLP_MEMBER_TEMPLATES)
00177   template <class _InputIterator>
00178   deque(_InputIterator __first, _InputIterator __last,
00179         const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
00180 #if !defined (_STLP_USE_ITERATOR_WRAPPER)
00181   : _M_impl(__first, __last,
00182             _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {
00183 #else
00184   : _M_impl(_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {
00185 #endif
00186 #if defined (_STLP_USE_ITERATOR_WRAPPER)
00187     insert(end(), __first, __last);
00188 #endif
00189   }
00190 
00191 #  if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
00192   template <class _InputIterator>
00193   deque(_InputIterator __first, _InputIterator __last)
00194 #    if !defined (_STLP_USE_ITERATOR_WRAPPER)
00195     : _M_impl(__first, __last) {}
00196 #    else
00197   { insert(end(), __first, __last); }
00198 #    endif
00199 #  endif
00200 
00201 #else
00202   deque(const_pointer __first, const_pointer __last,
00203         const allocator_type& __a = allocator_type() )
00204     : _M_impl(cast_traits::to_storage_type_cptr(__first),
00205               cast_traits::to_storage_type_cptr(__last),
00206               _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {}
00207 
00208   deque(const_iterator __first, const_iterator __last,
00209         const allocator_type& __a = allocator_type() )
00210     : _M_impl(ite_cast_traits::to_storage_type_cite(__first),
00211               ite_cast_traits::to_storage_type_cite(__last),
00212               _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {}
00213 #endif /* _STLP_MEMBER_TEMPLATES */
00214 
00215 #if !defined (_STLP_NO_MOVE_SEMANTIC)
00216   deque(__move_source<_Self> src)
00217     : _M_impl(__move_source<_Base>(src.get()._M_impl)) {}
00218 #endif
00219 
00220   _Self& operator= (const _Self& __x) { _M_impl = __x._M_impl; return *this; }
00221 
00222   void swap(_Self& __x) { _M_impl.swap(__x._M_impl); }
00223 #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
00224   void _M_swap_workaround(_Self& __x) { swap(__x); }
00225 #endif
00226 
00227   void assign(size_type __n, const value_type& __val) {
00228     _M_impl.assign(__n, cast_traits::to_storage_type_cref(__val));
00229   }
00230 
00231 #if defined (_STLP_MEMBER_TEMPLATES)
00232 #  if defined (_STLP_USE_ITERATOR_WRAPPER)
00233 private:
00234   template <class _Integer>
00235   void _M_assign_dispatch(_Integer __n, _Integer __val,
00236                           const __true_type&)
00237   { _M_impl.assign(__n, __val); }
00238 
00239   template <class _InputIterator>
00240   void _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
00241                           const __false_type&) {
00242     _M_impl.assign(_STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__first),
00243                    _STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__last));
00244   }
00245 
00246 public:
00247 #  endif
00248   template <class _InputIterator>
00249   void assign(_InputIterator __first, _InputIterator __last) {
00250 #  if defined (_STLP_USE_ITERATOR_WRAPPER)
00251     typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
00252     _M_assign_dispatch(__first, __last, _Integral());
00253 #  else
00254     _M_impl.assign(__first, __last);
00255 #  endif
00256   }
00257 #else
00258   void assign(const_pointer __first, const_pointer __last)
00259   { _M_impl.assign(cast_traits::to_storage_type_cptr(__first),
00260                    cast_traits::to_storage_type_cptr(__last)); }
00261   void assign(const_iterator __first, const_iterator __last)
00262   { _M_impl.assign(ite_cast_traits::to_storage_type_cite(__first),
00263                    ite_cast_traits::to_storage_type_cite(__last)); }
00264 #endif /* _STLP_MEMBER_TEMPLATES */
00265 
00266 #if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
00267   void push_back(const value_type& __t = _STLP_DEFAULT_CONSTRUCTED(value_type))
00268 #else
00269   void push_back(const value_type& __t)
00270 #endif 
00271   { _M_impl.push_back(cast_traits::to_storage_type_cref(__t)); }
00272 
00273 #if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
00274   void push_front(const value_type& __t = _STLP_DEFAULT_CONSTRUCTED(value_type))
00275 #else
00276   void push_front(const value_type& __t)
00277 #endif 
00278   { _M_impl.push_front(cast_traits::to_storage_type_cref(__t)); }
00279 
00280 # if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
00281   void push_back()  { _M_impl.push_back(); }
00282   void push_front() { _M_impl.push_front(); }
00283 # endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
00284 
00285   void pop_back()  { _M_impl.pop_back(); }
00286   void pop_front() { _M_impl.pop_front(); }
00287 
00288 #if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
00289   iterator insert(iterator __pos, const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type))
00290 #else
00291   iterator insert(iterator __pos, const value_type& __x)
00292 #endif 
00293   { return ite_cast_traits::to_value_type_ite(_M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos),
00294                                                              cast_traits::to_storage_type_cref(__x))); }
00295 
00296 #if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
00297   iterator insert(iterator __pos) { return insert(__pos, _STLP_DEFAULT_CONSTRUCTED(value_type)); }
00298 #endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
00299 
00300   void insert(iterator __pos, size_type __n, const value_type& __x)
00301   { _M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos), __n, cast_traits::to_storage_type_cref(__x)); }
00302 
00303 #if defined (_STLP_MEMBER_TEMPLATES)
00304 #  if defined (_STLP_USE_ITERATOR_WRAPPER)
00305 private:
00306   template <class _Integer>
00307   void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val,
00308                           const __true_type&) {
00309     _M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos), __n, __val);
00310   }
00311 
00312   template <class _InputIterator>
00313   void _M_insert_dispatch(iterator __pos,
00314                           _InputIterator __first, _InputIterator __last,
00315                           const __false_type&) {
00316     _M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos),
00317                    _STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__first),
00318                    _STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__last));
00319   }
00320 
00321 public:
00322 #  endif
00323 
00324   template <class _InputIterator>
00325   void insert(iterator __pos, _InputIterator __first, _InputIterator __last) {
00326 #  if defined (_STLP_USE_ITERATOR_WRAPPER)
00327     // Check whether it's an integral type.  If so, it's not an iterator.
00328     typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
00329     _M_insert_dispatch(__pos, __first, __last, _Integral());
00330 #  else
00331     _M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos), __first, __last);
00332 #  endif
00333   }
00334 
00335 #else /* _STLP_MEMBER_TEMPLATES */
00336   void insert(iterator __pos,
00337               const_pointer __first, const_pointer __last) {
00338     _M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos),
00339                    cast_traits::to_storage_type_cptr(__first),
00340                    cast_traits::to_storage_type_cptr(__last));
00341   }
00342   void insert(iterator __pos,
00343               const_iterator __first, const_iterator __last) {
00344     _M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos),
00345                    ite_cast_traits::to_storage_type_cite(__first),
00346                    ite_cast_traits::to_storage_type_cite(__last));
00347   }
00348 
00349 #endif /* _STLP_MEMBER_TEMPLATES */
00350 
00351 #if !defined (_STLP_DONT_SUP_DFLT_PARAM)
00352   void resize(size_type __new_size, const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type))
00353 #else
00354   void resize(size_type __new_size, const value_type& __x)
00355 #endif /*_STLP_DONT_SUP_DFLT_PARAM*/
00356   { _M_impl.resize(__new_size, cast_traits::to_storage_type_cref(__x)); }
00357 
00358 #if defined (_STLP_DONT_SUP_DFLT_PARAM)
00359   void resize(size_type __new_size) { _M_impl.resize(__new_size); }
00360 #endif /*_STLP_DONT_SUP_DFLT_PARAM*/
00361 
00362   iterator erase(iterator __pos)
00363   { return ite_cast_traits::to_value_type_ite(_M_impl.erase(ite_cast_traits::to_storage_type_ite(__pos))); }
00364 
00365   iterator erase(iterator __first, iterator __last)
00366   { return ite_cast_traits::to_value_type_ite(_M_impl.erase(ite_cast_traits::to_storage_type_ite(__first),
00367                                                             ite_cast_traits::to_storage_type_ite(__last))); }
00368   void clear() { _M_impl.clear(); }
00369 
00370 private:
00371   _Base _M_impl;
00372 };
00373 
00374 #if defined (deque)
00375 #  undef deque
00376 _STLP_MOVE_TO_STD_NAMESPACE
00377 #endif
00378 
00379 #undef DEQUE_IMPL
00380 #if defined (__BORLANDC__) || defined (__DMC__)
00381 #  undef typename
00382 #endif
00383 
00384 _STLP_END_NAMESPACE
00385 
00386 #endif /* _STLP_SPECIALIZED_DEQUE_H */
00387 
00388 // Local Variables:
00389 // mode:C++
00390 // End:

Generated on Thu May 24 2012 04:29:38 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.