Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygen_deque.h
Go to the documentation of this file.
00001 /* 00002 * 00003 * Copyright (c) 1994 00004 * Hewlett-Packard Company 00005 * 00006 * Copyright (c) 1996,1997 00007 * Silicon Graphics Computer Systems, Inc. 00008 * 00009 * Copyright (c) 1997 00010 * Moscow Center for SPARC Technology 00011 * 00012 * Copyright (c) 1999 00013 * Boris Fomitchev 00014 * 00015 * This material is provided "as is", with absolutely no warranty expressed 00016 * or implied. Any use is at your own risk. 00017 * 00018 * Permission to use or copy this software for any purpose is hereby granted 00019 * without fee, provided the above notices are retained on all copies. 00020 * Permission to modify the code and to distribute modified code is granted, 00021 * provided the above notices are retained, and a notice that the code was 00022 * modified is included with the above copyright notice. 00023 * 00024 */ 00025 00026 /* NOTE: This is an internal header file, included by other STL headers. 00027 * You should not attempt to use it directly. 00028 */ 00029 00030 #ifndef _STLP_INTERNAL_DBG_DEQUE_H 00031 #define _STLP_INTERNAL_DBG_DEQUE_H 00032 00033 #ifndef _STLP_DBG_ITERATOR_H 00034 # include <stl/debug/_iterator.h> 00035 #endif 00036 00037 #define _STLP_NON_DBG_DEQUE _STLP_PRIV _STLP_NON_DBG_NAME(deque) <_Tp,_Alloc> 00038 00039 _STLP_BEGIN_NAMESPACE 00040 00041 #if defined (_STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS) 00042 template <class _Tp, class _Alloc> 00043 inline _Tp* value_type(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_DEQUE >&) 00044 { return (_Tp*)0; } 00045 template <class _Tp, class _Alloc> 00046 inline random_access_iterator_tag iterator_category(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_DEQUE >&) 00047 { return random_access_iterator_tag(); } 00048 #endif 00049 00050 template <class _Tp, _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Tp>) > 00051 class deque : 00052 #if !defined (__DMC__) 00053 private 00054 #endif 00055 _STLP_PRIV __construct_checker<_STLP_NON_DBG_DEQUE > 00056 #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) 00057 , public __stlport_class<deque<_Tp, _Alloc> > 00058 #endif 00059 { 00060 typedef deque<_Tp,_Alloc> _Self; 00061 typedef _STLP_NON_DBG_DEQUE _Base; 00062 typedef _STLP_PRIV __construct_checker<_STLP_NON_DBG_DEQUE > _ConstructCheck; 00063 00064 public: 00065 // Basic types 00066 __IMPORT_CONTAINER_TYPEDEFS(_Base) 00067 00068 // Iterators 00069 typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_Nonconst_traits<value_type> > > iterator; 00070 typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_Const_traits<value_type> > > const_iterator; 00071 00072 _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS; 00073 00074 protected: 00075 _Base _M_non_dbg_impl; 00076 _STLP_PRIV __owned_list _M_iter_list; 00077 00078 void _Invalidate_all() 00079 { _M_iter_list._Invalidate_all(); } 00080 void _Invalidate_iterator(const iterator& __it) 00081 { _STLP_PRIV __invalidate_iterator(&_M_iter_list,__it); } 00082 void _Invalidate_iterators(const iterator& __first, const iterator& __last) 00083 { _STLP_PRIV __invalidate_range(&_M_iter_list, __first, __last); } 00084 00085 public: 00086 // Basic accessors 00087 allocator_type get_allocator() const { return _M_non_dbg_impl.get_allocator(); } 00088 00089 iterator begin() { return iterator(&_M_iter_list, _M_non_dbg_impl.begin()); } 00090 iterator end() { return iterator(&_M_iter_list, _M_non_dbg_impl.end()); } 00091 const_iterator begin() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.begin()); } 00092 const_iterator end() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.end()); } 00093 00094 reverse_iterator rbegin() { return reverse_iterator(end()); } 00095 reverse_iterator rend() { return reverse_iterator(begin()); } 00096 const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } 00097 const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } 00098 00099 reference operator[](size_type __n) { 00100 _STLP_VERBOSE_ASSERT(__n < size(), _StlMsg_OUT_OF_BOUNDS) 00101 return _M_non_dbg_impl[__n]; 00102 } 00103 const_reference operator[](size_type __n) const { 00104 _STLP_VERBOSE_ASSERT(__n < size(), _StlMsg_OUT_OF_BOUNDS) 00105 return _M_non_dbg_impl[__n]; 00106 } 00107 00108 reference at(size_type __n) { return _M_non_dbg_impl.at(__n); } 00109 const_reference at(size_type __n) const { return _M_non_dbg_impl.at(__n); } 00110 00111 reference front() { 00112 _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER) 00113 return *begin(); 00114 } 00115 const_reference front() const { 00116 _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER) 00117 return *begin(); 00118 } 00119 reference back() { 00120 _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER) 00121 return *(--end()); 00122 } 00123 const_reference back() const { 00124 _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER) 00125 return *(--end()); 00126 } 00127 00128 // Constructor, destructor. 00129 explicit deque(const allocator_type& __a = allocator_type()) : 00130 _M_non_dbg_impl(__a), _M_iter_list(&_M_non_dbg_impl) {} 00131 deque(const _Self& __x) : 00132 _ConstructCheck(__x), _M_non_dbg_impl(__x._M_non_dbg_impl), 00133 _M_iter_list(&_M_non_dbg_impl) {} 00134 00135 #if !defined(_STLP_DONT_SUP_DFLT_PARAM) 00136 explicit deque(size_type __n, const value_type& __x = _Tp(), 00137 #else 00138 deque(size_type __n, const value_type& __x, 00139 #endif /*_STLP_DONT_SUP_DFLT_PARAM*/ 00140 const allocator_type& __a = allocator_type()) : 00141 _M_non_dbg_impl(__n, __x, __a), _M_iter_list(&_M_non_dbg_impl) {} 00142 #if defined (_STLP_DONT_SUP_DFLT_PARAM) 00143 explicit deque(size_type __n) : 00144 _M_non_dbg_impl(__n), _M_iter_list(&_M_non_dbg_impl) {} 00145 #endif /*_STLP_DONT_SUP_DFLT_PARAM*/ 00146 00147 #if !defined (_STLP_NO_MOVE_SEMANTIC) 00148 deque(__move_source<_Self> src) 00149 : _M_non_dbg_impl(__move_source<_Base>(src.get()._M_non_dbg_impl)), 00150 _M_iter_list(&_M_non_dbg_impl) { 00151 # if defined (_STLP_NO_EXTENSIONS) || (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL) 00152 src.get()._M_iter_list._Invalidate_all(); 00153 # else 00154 src.get()._M_iter_list._Set_owner(_M_iter_list); 00155 # endif 00156 } 00157 #endif 00158 00159 #if defined (_STLP_MEMBER_TEMPLATES) 00160 template <class _InputIterator> 00161 deque(_InputIterator __first, _InputIterator __last, 00162 const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) 00163 : _ConstructCheck(__first, __last), 00164 _M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last), __a), 00165 _M_iter_list(&_M_non_dbg_impl) { 00166 } 00167 # if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) 00168 template <class _InputIterator> 00169 deque(_InputIterator __first, _InputIterator __last) 00170 : _ConstructCheck(__first, __last), 00171 _M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last)), 00172 _M_iter_list(&_M_non_dbg_impl) { 00173 } 00174 # endif 00175 #else 00176 deque(const value_type* __first, const value_type* __last, 00177 const allocator_type& __a = allocator_type()) 00178 : _ConstructCheck(__first, __last), 00179 _M_non_dbg_impl(__first, __last, __a), 00180 _M_iter_list(&_M_non_dbg_impl) { 00181 } 00182 00183 deque(const_iterator __first, const_iterator __last, 00184 const allocator_type& __a = allocator_type()) 00185 : _ConstructCheck(__first, __last), 00186 _M_non_dbg_impl(__first._M_iterator, __last._M_iterator, __a), 00187 _M_iter_list(&_M_non_dbg_impl) { 00188 } 00189 #endif 00190 00191 _Self& operator=(const _Self& __x) { 00192 if (this != &__x) { 00193 _Invalidate_all(); 00194 _M_non_dbg_impl = __x._M_non_dbg_impl; 00195 } 00196 return *this; 00197 } 00198 00199 bool empty() const { return _M_non_dbg_impl.empty(); } 00200 size_type size() const { return _M_non_dbg_impl.size(); } 00201 size_type max_size() const { return _M_non_dbg_impl.max_size(); } 00202 00203 void swap(_Self& __x) { 00204 _M_iter_list._Swap_owners(__x._M_iter_list); 00205 _M_non_dbg_impl.swap(__x._M_non_dbg_impl); 00206 } 00207 #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) 00208 void _M_swap_workaround(_Self& __x) { swap(__x); } 00209 #endif 00210 00211 public: 00212 void assign(size_type __n, const _Tp& __val) { 00213 _Invalidate_all(); 00214 _M_non_dbg_impl.assign(__n, __val); 00215 } 00216 00217 #if defined (_STLP_MEMBER_TEMPLATES) 00218 template <class _InputIterator> 00219 void assign(_InputIterator __first, _InputIterator __last) { 00220 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) 00221 _Invalidate_all(); 00222 _M_non_dbg_impl.assign(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last)); 00223 } 00224 #else 00225 void assign(const_iterator __first, const_iterator __last) { 00226 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) 00227 _Invalidate_all(); 00228 _M_non_dbg_impl.assign(__first._M_iterator, __last._M_iterator); 00229 } 00230 void assign(const value_type *__first, const value_type *__last) { 00231 _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__first, __last)) 00232 _Invalidate_all(); 00233 _M_non_dbg_impl.assign(__first, __last); 00234 } 00235 #endif 00236 00237 public: // push_* and pop_* 00238 00239 #if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS) 00240 void push_back(const value_type& __t = _Tp()) { 00241 #else 00242 void push_back(const value_type& __t) { 00243 #endif 00244 _Invalidate_all(); 00245 _M_non_dbg_impl.push_back(__t); 00246 } 00247 00248 #if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS) 00249 void push_back() { 00250 _Invalidate_all(); 00251 _M_non_dbg_impl.push_back(); 00252 } 00253 #endif 00254 00255 #if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS) 00256 void push_front(const value_type& __t = _Tp()) { 00257 #else 00258 void push_front(const value_type& __t) { 00259 #endif 00260 _Invalidate_all(); 00261 _M_non_dbg_impl.push_front(__t); 00262 } 00263 00264 #if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS) 00265 void push_front() { 00266 _Invalidate_all(); 00267 _M_non_dbg_impl.push_front(); 00268 } 00269 #endif 00270 00271 void pop_back() { 00272 _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER) 00273 _Invalidate_iterator(end()); 00274 _M_non_dbg_impl.pop_back(); 00275 } 00276 00277 void pop_front() { 00278 _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER) 00279 _Invalidate_iterator(begin()); 00280 _M_non_dbg_impl.pop_front(); 00281 } 00282 00283 public: // Insert 00284 00285 #if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS) 00286 iterator insert(iterator __pos, const value_type& __x = _Tp()) { 00287 #else 00288 iterator insert(iterator __pos, const value_type& __x) { 00289 #endif 00290 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) 00291 _Invalidate_all(); 00292 return iterator(&_M_iter_list, _M_non_dbg_impl.insert(__pos._M_iterator, __x)); 00293 } 00294 00295 #if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS) 00296 iterator insert(iterator __pos) { 00297 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) 00298 _Invalidate_all(); 00299 return iterator(&_M_iter_list, _M_non_dbg_impl.insert(__pos._M_iterator)); 00300 } 00301 #endif 00302 00303 void insert(iterator __pos, size_type __n, const value_type& __x) { 00304 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) 00305 if (__n != 0) _Invalidate_all(); 00306 _M_non_dbg_impl.insert(__pos._M_iterator, __n, __x); 00307 } 00308 00309 #if defined (_STLP_MEMBER_TEMPLATES) 00310 template <class _InputIterator> 00311 void insert(iterator __pos, _InputIterator __first, _InputIterator __last) { 00312 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) 00313 // We perform invalidate first to detect self referencing in __check_range as __first and __last 00314 // will have been invalidated. 00315 if (__first != __last) _Invalidate_all(); 00316 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) 00317 _M_non_dbg_impl.insert(__pos._M_iterator, 00318 _STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last)); 00319 } 00320 #endif 00321 00322 #if !defined (_STLP_MEMBER_TEMPLATES) 00323 void insert(iterator __pos, 00324 const value_type* __first, const value_type* __last) { 00325 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) 00326 _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__first, __last)) 00327 if (__first != __last) _Invalidate_all(); 00328 _M_non_dbg_impl.insert(__pos._M_iterator, __first, __last); 00329 } 00330 #endif 00331 00332 #if !defined (_STLP_MEMBER_TEMPLATES) || !defined (_STLP_NO_METHOD_SPECIALIZATION) 00333 void insert(iterator __pos, 00334 const_iterator __first, const_iterator __last) { 00335 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) 00336 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) 00337 //Sequence requirements 23.1.1 Table 67: 00338 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_not_owner(&_M_iter_list, __first)); 00339 if (__first != __last) _Invalidate_all(); 00340 _M_non_dbg_impl.insert(__pos._M_iterator, __first._M_iterator, __last._M_iterator); 00341 } 00342 00343 void insert(iterator __pos, 00344 iterator __first, iterator __last) { 00345 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) 00346 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last)) 00347 //Sequence requirements 23.1.1 Table 67: 00348 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_not_owner(&_M_iter_list, __first)); 00349 if (__first != __last) _Invalidate_all(); 00350 _M_non_dbg_impl.insert(__pos._M_iterator, __first._M_iterator, __last._M_iterator); 00351 } 00352 #endif 00353 00354 #if !defined (_STLP_DONT_SUP_DFLT_PARAM) 00355 void resize(size_type __new_size, const value_type& __x = _Tp()) { 00356 #else 00357 void resize(size_type __new_size, const value_type& __x) { 00358 #endif 00359 if (__new_size != size()) { 00360 if ((__new_size > size()) || (__new_size < size() - 1)) 00361 _Invalidate_all(); 00362 else 00363 _Invalidate_iterator(end()); 00364 } 00365 _M_non_dbg_impl.resize(__new_size, __x); 00366 } 00367 00368 #if defined (_STLP_DONT_SUP_DFLT_PARAM) 00369 void resize(size_type new_size) { resize(new_size, _STLP_DEFAULT_CONSTRUCTED(_Tp)); } 00370 #endif 00371 00372 // Erase 00373 iterator erase(iterator __pos) { 00374 _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos)) 00375 _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos)) 00376 if (__pos._M_iterator == _M_non_dbg_impl.begin()) { 00377 _Invalidate_iterator(__pos); 00378 } else { 00379 typename _Base::iterator tmp = --(_M_non_dbg_impl.end()); 00380 if (__pos._M_iterator == tmp) 00381 _Invalidate_iterator(__pos); 00382 else 00383 _Invalidate_all(); 00384 } 00385 return iterator (&_M_iter_list, _M_non_dbg_impl.erase(__pos._M_iterator)); 00386 } 00387 00388 iterator erase(iterator __first, iterator __last) { 00389 _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, begin(), end())) 00390 if (!empty()) { 00391 if (__first._M_iterator == _M_non_dbg_impl.begin() || 00392 __last._M_iterator == _M_non_dbg_impl.end()) 00393 _Invalidate_iterators(__first, __last); 00394 else 00395 _Invalidate_all(); 00396 } 00397 return iterator (&_M_iter_list, _M_non_dbg_impl.erase(__first._M_iterator, __last._M_iterator)); 00398 } 00399 00400 void clear() { 00401 _Invalidate_all(); 00402 _M_non_dbg_impl.clear(); 00403 } 00404 }; 00405 00406 _STLP_END_NAMESPACE 00407 00408 #undef _STLP_NON_DBG_DEQUE 00409 00410 #endif /* _STLP_INTERNAL_DEQUE_H */ 00411 00412 // Local Variables: 00413 // mode:C++ 00414 // End: Generated on Sun May 27 2012 04:29:00 for ReactOS by
1.7.6.1
|