/home/ntakagi/work/STLport-5.1.5/stlport/stl/pointers/_list.hGo to the documentation of this file.00001 /* 00002 * Copyright (c) 2003 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_PTR_SPECIALIZED_LIST_H 00021 #define _STLP_PTR_SPECIALIZED_LIST_H 00022 00023 #ifndef _STLP_POINTERS_SPEC_TOOLS_H 00024 # include <stl/pointers/_tools.h> 00025 #endif 00026 00027 _STLP_BEGIN_NAMESPACE 00028 00029 #define LIST_IMPL _STLP_PTR_IMPL_NAME(list) 00030 00031 #if defined (_STLP_USE_TEMPLATE_EXPORT) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) 00032 00033 _STLP_MOVE_TO_PRIV_NAMESPACE 00034 00035 _STLP_EXPORT_TEMPLATE_CLASS _List_node<void*>; 00036 00037 _STLP_MOVE_TO_STD_NAMESPACE 00038 00039 _STLP_EXPORT_TEMPLATE_CLASS allocator<_STLP_PRIV _List_node<void*> >; 00040 00041 _STLP_MOVE_TO_PRIV_NAMESPACE 00042 00043 _STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<_List_node_base, _List_node<void*>, allocator<_List_node<void*> > >; 00044 _STLP_EXPORT_TEMPLATE_CLASS _List_base<void*, allocator<void*> >; 00045 _STLP_EXPORT_TEMPLATE_CLASS LIST_IMPL<void*, allocator<void*> >; 00046 00047 _STLP_MOVE_TO_STD_NAMESPACE 00048 #endif 00049 00050 #if defined (_STLP_DEBUG) 00051 # define list _STLP_NON_DBG_NAME(list) 00052 _STLP_MOVE_TO_PRIV_NAMESPACE 00053 #endif 00054 00055 template <class _Tp, _STLP_DEFAULT_ALLOCATOR_SELECT(_Tp) > 00056 class list 00057 #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (list) 00058 : public __stlport_class<list<_Tp, _Alloc> > 00059 #endif 00060 { 00061 typedef typename _STLP_PRIV _StorageType<_Tp>::_Type _StorageType; 00062 typedef typename _Alloc_traits<_StorageType, _Alloc>::allocator_type _StorageTypeAlloc; 00063 typedef _STLP_PRIV LIST_IMPL<_StorageType, _StorageTypeAlloc> _Base; 00064 typedef typename _Base::iterator _BaseIte; 00065 typedef typename _Base::const_iterator _BaseConstIte; 00066 typedef _STLP_PRIV _CastTraits<_StorageType, _Tp> cast_traits; 00067 typedef list<_Tp, _Alloc> _Self; 00068 00069 public: 00070 typedef _Tp value_type; 00071 typedef value_type* pointer; 00072 typedef const value_type* const_pointer; 00073 typedef value_type& reference; 00074 typedef const value_type& const_reference; 00075 typedef size_t size_type; 00076 typedef ptrdiff_t difference_type; 00077 _STLP_FORCE_ALLOCATORS(value_type, _Alloc) 00078 typedef typename _Alloc_traits<value_type, _Alloc>::allocator_type allocator_type; 00079 typedef bidirectional_iterator_tag _Iterator_category; 00080 00081 typedef _STLP_PRIV _List_iterator<value_type, _Nonconst_traits<value_type> > iterator; 00082 typedef _STLP_PRIV _List_iterator<value_type, _Const_traits<value_type> > const_iterator; 00083 00084 _STLP_DECLARE_BIDIRECTIONAL_REVERSE_ITERATORS; 00085 00086 allocator_type get_allocator() const 00087 { return _STLP_CONVERT_ALLOCATOR(_M_impl.get_allocator(), value_type); } 00088 00089 # if !(defined(__MRC__)||(defined(__SC__) && !defined(__DMC__))) 00090 explicit 00091 # endif 00092 list(const allocator_type& __a = allocator_type()) 00093 : _M_impl(_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {} 00094 00095 #if !defined(_STLP_DONT_SUP_DFLT_PARAM) 00096 explicit list(size_type __n, const value_type& __val = _STLP_DEFAULT_CONSTRUCTED(value_type), 00097 #else 00098 list(size_type __n, const value_type& __val, 00099 #endif /*_STLP_DONT_SUP_DFLT_PARAM*/ 00100 const allocator_type& __a = allocator_type()) 00101 : _M_impl(__n, cast_traits::to_storage_type_cref(__val), 00102 _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {} 00103 00104 #if defined(_STLP_DONT_SUP_DFLT_PARAM) 00105 explicit list(size_type __n) 00106 : _M_impl(__n) {} 00107 #endif /*_STLP_DONT_SUP_DFLT_PARAM*/ 00108 00109 #if defined (_STLP_MEMBER_TEMPLATES) 00110 template <class _InputIterator> 00111 list(_InputIterator __first, _InputIterator __last, 00112 const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) 00113 # if !defined (_STLP_USE_ITERATOR_WRAPPER) 00114 : _M_impl(__first, __last, _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {} 00115 # else 00116 : _M_impl(_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) { 00117 insert(begin(), __first, __last); 00118 } 00119 # endif 00120 00121 # if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) 00122 template <class _InputIterator> 00123 list(_InputIterator __first, _InputIterator __last) 00124 # if !defined (_STLP_USE_WRAPPER_ITERATOR) 00125 : _M_impl(__first, __last) {} 00126 # else 00127 { insert(begin(), __first, __last); } 00128 # endif 00129 # endif 00130 00131 #else /* _STLP_MEMBER_TEMPLATES */ 00132 00133 list(const value_type *__first, const value_type *__last, 00134 const allocator_type& __a = allocator_type()) 00135 : _M_impl(cast_traits::to_storage_type_cptr(__first), 00136 cast_traits::to_storage_type_cptr(__last), 00137 _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {} 00138 list(const_iterator __first, const_iterator __last, 00139 const allocator_type& __a = allocator_type()) 00140 : _M_impl(_BaseConstIte(__first._M_node), _BaseConstIte(__last._M_node), 00141 _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {} 00142 00143 #endif /* _STLP_MEMBER_TEMPLATES */ 00144 00145 list(const _Self& __x) : _M_impl(__x._M_impl) {} 00146 00147 list(__move_source<_Self> src) 00148 : _M_impl(__move_source<_Base>(src.get()._M_impl)) {} 00149 00150 iterator begin() { return iterator(_M_impl.begin()._M_node); } 00151 const_iterator begin() const { return const_iterator(_M_impl.begin()._M_node); } 00152 00153 iterator end() { return iterator(_M_impl.end()._M_node); } 00154 const_iterator end() const { return const_iterator(_M_impl.end()._M_node); } 00155 00156 reverse_iterator rbegin() { return reverse_iterator(end()); } 00157 const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } 00158 00159 reverse_iterator rend() { return reverse_iterator(begin()); } 00160 const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } 00161 00162 bool empty() const { return _M_impl.empty(); } 00163 size_type size() const { return _M_impl.size(); } 00164 size_type max_size() const { return _M_impl.max_size(); } 00165 00166 reference front() { return *begin(); } 00167 const_reference front() const { return *begin(); } 00168 reference back() { return *(--end()); } 00169 const_reference back() const { return *(--end()); } 00170 00171 void swap(_Self &__x) { _M_impl.swap(__x._M_impl); } 00172 void clear() { _M_impl.clear(); } 00173 00174 #if !defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS) 00175 iterator insert(iterator __pos, const_reference __x = _STLP_DEFAULT_CONSTRUCTED(value_type)) 00176 #else 00177 iterator insert(iterator __pos, const_reference __x) 00178 #endif 00179 { return iterator(_M_impl.insert(_BaseIte(__pos._M_node), 00180 cast_traits::to_storage_type_cref(__x))._M_node); } 00181 00182 #if defined (_STLP_MEMBER_TEMPLATES) 00183 # if defined (_STLP_USE_ITERATOR_WRAPPER) 00184 private: 00185 template <class _Integer> 00186 void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val, 00187 const __true_type&) 00188 { _M_impl.insert(_BaseIte(__pos._M_node), __n, __val); } 00189 00190 template <class _InputIterator> 00191 void _M_insert_dispatch(iterator __pos, 00192 _InputIterator __first, _InputIterator __last, 00193 const __false_type&) { 00194 _M_impl.insert(_BaseIte(__pos._M_node), 00195 typename _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__first), 00196 typename _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__last)); 00197 } 00198 00199 public: 00200 # endif 00201 00202 template <class _InputIterator> 00203 void insert(iterator __pos, _InputIterator __first, _InputIterator __last) { 00204 # if defined (_STLP_USE_ITERATOR_WRAPPER) 00205 // Check whether it's an integral type. If so, it's not an iterator. 00206 typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; 00207 _M_insert_dispatch(__pos, __first, __last, _Integral()); 00208 # else 00209 _M_impl.insert(_BaseIte(__pos._M_node), __first, __last); 00210 # endif 00211 } 00212 #else /* _STLP_MEMBER_TEMPLATES */ 00213 void insert(iterator __pos, const value_type *__first, const value_type *__last) 00214 { _M_impl.insert(_BaseIte(__pos._M_node), cast_traits::to_storage_type_cptr(__first), 00215 cast_traits::to_storage_type_cptr(__last)); } 00216 void insert(iterator __pos, const_iterator __first, const_iterator __last) 00217 { _M_impl.insert(_BaseIte(__pos._M_node), _BaseConstIte(__first._M_node), _BaseConstIte(__last._M_node)); } 00218 #endif /* _STLP_MEMBER_TEMPLATES */ 00219 00220 void insert(iterator __pos, size_type __n, const value_type& __x) 00221 { _M_impl.insert(_BaseIte(__pos._M_node), __n, cast_traits::to_storage_type_cref(__x)); } 00222 00223 void push_front(const value_type& __x) { _M_impl.push_front(cast_traits::to_storage_type_cref(__x)); } 00224 void push_back(const value_type& __x) { _M_impl.push_back(cast_traits::to_storage_type_cref(__x)); } 00225 00226 #if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS) 00227 iterator insert(iterator __pos) { return iterator(_M_impl.insert(__pos._M_node)._M_node); } 00228 void push_front() { _M_impl.push_front();} 00229 void push_back() { _M_impl.push_back();} 00230 # endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/ 00231 00232 iterator erase(iterator __pos) 00233 { return iterator(_M_impl.erase(_BaseIte(__pos._M_node))._M_node); } 00234 iterator erase(iterator __first, iterator __last) 00235 { return iterator(_M_impl.erase(_BaseIte(__first._M_node), _BaseIte(__last._M_node))._M_node); } 00236 00237 #if !defined(_STLP_DONT_SUP_DFLT_PARAM) 00238 void resize(size_type __new_size, const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type)) 00239 #else 00240 void resize(size_type __new_size) { _M_impl.resize(__new_size); } 00241 void resize(size_type __new_size, const value_type& __x) 00242 #endif 00243 {_M_impl.resize(__new_size, cast_traits::to_storage_type_cref(__x));} 00244 00245 void pop_front() { _M_impl.pop_front(); } 00246 void pop_back() { _M_impl.pop_back(); } 00247 00248 _Self& operator=(const _Self& __x) 00249 { _M_impl = __x._M_impl; return *this; } 00250 void assign(size_type __n, const value_type& __val) 00251 { _M_impl.assign(__n, cast_traits::to_storage_type_cref(__val)); } 00252 00253 #if defined (_STLP_MEMBER_TEMPLATES) 00254 # if defined (_STLP_USE_ITERATOR_WRAPPER) 00255 private: 00256 template <class _Integer> 00257 void _M_assign_dispatch(_Integer __n, _Integer __val, const __true_type&) 00258 { _M_impl.assign(__n, __val); } 00259 00260 template <class _InputIterator> 00261 void _M_assign_dispatch(_InputIterator __first, _InputIterator __last, 00262 const __false_type&) { 00263 _M_impl.assign(typename _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__first), 00264 typename _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__last)); 00265 } 00266 00267 public: 00268 # endif 00269 00270 template <class _InputIterator> 00271 void assign(_InputIterator __first, _InputIterator __last) { 00272 # if defined (_STLP_USE_ITERATOR_WRAPPER) 00273 typedef typename _IsIntegral<_InputIterator>::_Ret _Integral; 00274 _M_assign_dispatch(__first, __last, _Integral()); 00275 # else 00276 _M_impl.assign(__first, __last); 00277 # endif 00278 } 00279 #else 00280 void assign(const value_type *__first, const value_type *__last) { 00281 _M_impl.assign(cast_traits::to_storage_type_cptr(__first), 00282 cast_traits::to_storage_type_cptr(__last)); 00283 } 00284 void assign(const_iterator __first, const_iterator __last) 00285 { _M_impl.assign(_BaseConstIte(__first._M_node), _BaseConstIte(__last._M_node)); } 00286 #endif 00287 00288 void splice(iterator __pos, _Self& __x) 00289 { _M_impl.splice(_BaseIte(__pos._M_node), __x._M_impl); } 00290 void splice(iterator __pos, _Self& __x, iterator __i) 00291 { _M_impl.splice(_BaseIte(__pos._M_node), __x._M_impl, _BaseIte(__i._M_node)); } 00292 void splice(iterator __pos, _Self& __x, iterator __first, iterator __last) 00293 { _M_impl.splice(_BaseIte(__pos._M_node), __x._M_impl, 00294 _BaseIte(__first._M_node), _BaseIte(__last._M_node)); } 00295 00296 void remove(const_reference __val) 00297 { _M_impl.remove(cast_traits::to_storage_type_cref(__val)); } 00298 void unique() { _M_impl.unique(); } 00299 void merge(_Self& __x) { _M_impl.merge(__x._M_impl); } 00300 void reverse() { _M_impl.reverse(); } 00301 void sort() { _M_impl.sort(); } 00302 00303 #if defined (_STLP_MEMBER_TEMPLATES) 00304 template <class _Predicate> 00305 void remove_if(_Predicate __pred) 00306 { _M_impl.remove_if(_STLP_PRIV _UnaryPredWrapper<_StorageType, _Tp, _Predicate>(__pred)); } 00307 template <class _BinaryPredicate> 00308 void unique(_BinaryPredicate __bin_pred) 00309 { _M_impl.unique(_STLP_PRIV _BinaryPredWrapper<_StorageType, _Tp, _BinaryPredicate>(__bin_pred)); } 00310 00311 template <class _StrictWeakOrdering> 00312 void merge(_Self &__x, _StrictWeakOrdering __comp) 00313 { _M_impl.merge(__x._M_impl, _STLP_PRIV _BinaryPredWrapper<_StorageType, _Tp, _StrictWeakOrdering>(__comp)); } 00314 00315 template <class _StrictWeakOrdering> 00316 void sort(_StrictWeakOrdering __comp) 00317 { _M_impl.sort(_STLP_PRIV _BinaryPredWrapper<_StorageType, _Tp, _StrictWeakOrdering>(__comp)); } 00318 #endif /* _STLP_MEMBER_TEMPLATES */ 00319 00320 private: 00321 _Base _M_impl; 00322 }; 00323 00324 #if defined (list) 00325 # undef list 00326 _STLP_MOVE_TO_STD_NAMESPACE 00327 #endif 00328 00329 #undef LIST_IMPL 00330 00331 _STLP_END_NAMESPACE 00332 00333 #endif /* _STLP_PTR_SPECIALIZED_LIST_H */ 00334 00335 // Local Variables: 00336 // mode:C++ 00337 // End:
Generated on Mon Mar 10 15:32:30 2008 by ![]() |