/home/ntakagi/work/STLport-5.1.5/stlport/stl/pointers/_set.hGo to the documentation of this file.00001 /* 00002 * Copyright (c) 2005 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 /* NOTE: This is an internal header file, included by other STL headers. 00016 * You should not attempt to use it directly. 00017 */ 00018 00019 #ifndef _STLP_PTR_SPECIALIZED_SET_H 00020 #define _STLP_PTR_SPECIALIZED_SET_H 00021 00022 #ifndef _STLP_POINTERS_SPEC_TOOLS_H 00023 # include <stl/pointers/_tools.h> 00024 #endif 00025 00026 _STLP_BEGIN_NAMESPACE 00027 00028 //Specific iterator traits creation 00029 _STLP_CREATE_ITERATOR_TRAITS(SetTraitsT, Const_traits) 00030 00031 #if defined (_STLP_USE_TEMPLATE_EXPORT) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND) 00032 _STLP_EXPORT template struct _STLP_CLASS_DECLSPEC less<void*>; 00033 00034 _STLP_MOVE_TO_PRIV_NAMESPACE 00035 00036 typedef _Rb_tree_node<void*> _Node; 00037 _STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<_Rb_tree_node_base, _Node, allocator<_Node> >; 00038 _STLP_EXPORT_TEMPLATE_CLASS _Rb_tree_base<void*, allocator<void*> >; 00039 # if defined (_STLP_DEBUG) 00040 _STLP_EXPORT_TEMPLATE_CLASS _DbgCompare<void*, less<void*> >; 00041 # define _Rb_tree _STLP_NON_DBG_NAME(Rb_tree) 00042 _STLP_EXPORT_TEMPLATE_CLASS _Rb_tree<void*, _DbgCompare<void*, less<void*> >, void*, _Identity<void*>, 00043 _SetTraitsT<void*>, allocator<void*> >; 00044 # undef _Rb_tree 00045 # endif 00046 _STLP_EXPORT_TEMPLATE_CLASS _Rb_tree<void*, less<void*>, void*, _Identity<void*>, 00047 _SetTraitsT<void*>, allocator<void*> >; 00048 _STLP_MOVE_TO_STD_NAMESPACE 00049 #endif 00050 00051 template <class _Key, _STLP_DFL_TMPL_PARAM(_Compare, less<_Key>), 00052 _STLP_DEFAULT_ALLOCATOR_SELECT(_Key) > 00053 class set 00054 #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) 00055 : public __stlport_class<set<_Key, _Compare, _Alloc> > 00056 #endif 00057 { 00058 typedef _STLP_PRIV _AssocStorageTypes<_Key, _Compare> _AssocStorageTypes; 00059 typedef typename _AssocStorageTypes::_KeyStorageType _KeyStorageType; 00060 typedef typename _AssocStorageTypes::_CompareStorageType _CompareStorageType; 00061 typedef typename _Alloc_traits<_KeyStorageType, _Alloc>::allocator_type _StorageTypeAlloc; 00062 typedef _STLP_PRIV _CastTraits<_KeyStorageType, _Key> cast_traits; 00063 00064 typedef set<_Key, _Compare, _Alloc> _Self; 00065 public: 00066 typedef _Key key_type; 00067 typedef _Key value_type; 00068 typedef _Compare key_compare; 00069 typedef _Compare value_compare; 00070 00071 protected: 00072 //Specific iterator traits creation 00073 typedef _STLP_PRIV _SetTraitsT<value_type> _SetTraits; 00074 typedef _STLP_PRIV _Rb_tree<key_type, key_compare, 00075 value_type, _STLP_PRIV _Identity<value_type>, 00076 _SetTraits, _Alloc> _Priv_Rep_type; 00077 00078 typedef _STLP_PRIV _SetTraitsT<_KeyStorageType> _SetStorageTraits; 00079 00080 public: 00081 //dums: need the following public for the __move_traits framework 00082 typedef _STLP_PRIV _Rb_tree<_KeyStorageType, _CompareStorageType, 00083 _KeyStorageType, _STLP_PRIV _Identity<_KeyStorageType>, 00084 _SetStorageTraits, _StorageTypeAlloc> _Rep_type; 00085 00086 private: 00087 typedef typename _Rep_type::iterator base_iterator; 00088 typedef typename _Rep_type::const_iterator const_base_iterator; 00089 00090 public: 00091 typedef typename _Priv_Rep_type::pointer pointer; 00092 typedef typename _Priv_Rep_type::const_pointer const_pointer; 00093 typedef typename _Priv_Rep_type::reference reference; 00094 typedef typename _Priv_Rep_type::const_reference const_reference; 00095 typedef typename _Priv_Rep_type::iterator iterator; 00096 typedef typename _Priv_Rep_type::const_iterator const_iterator; 00097 typedef typename _Priv_Rep_type::reverse_iterator reverse_iterator; 00098 typedef typename _Priv_Rep_type::const_reverse_iterator const_reverse_iterator; 00099 typedef typename _Priv_Rep_type::size_type size_type; 00100 typedef typename _Priv_Rep_type::difference_type difference_type; 00101 typedef typename _Priv_Rep_type::allocator_type allocator_type; 00102 00103 private: 00104 _Rep_type _M_t; // red-black tree representing set 00105 _STLP_KEY_TYPE_FOR_CONT_EXT(key_type) 00106 00107 #if defined (_STLP_DEBUG) 00108 static iterator _S_to_value_ite(const_base_iterator __ite) 00109 { return iterator(__ite._Owner(), __ite._M_iterator._M_node); } 00110 static base_iterator _S_to_storage_ite(const_iterator __ite) 00111 { return base_iterator(__ite._Owner(), __ite._M_iterator._M_node); } 00112 #else 00113 static iterator _S_to_value_ite(const_base_iterator __ite) 00114 { return iterator(__ite._M_node); } 00115 static base_iterator _S_to_storage_ite(const_iterator __ite) 00116 { return base_iterator(__ite._M_node); } 00117 #endif 00118 00119 public: 00120 set() : _M_t(_CompareStorageType(), _StorageTypeAlloc()) {} 00121 explicit set(const _Compare& __comp, 00122 const allocator_type& __a = allocator_type()) 00123 : _M_t(__comp, _STLP_CONVERT_ALLOCATOR(__a, _KeyStorageType)) {} 00124 00125 #if defined (_STLP_MEMBER_TEMPLATES) 00126 template <class _InputIterator> 00127 set(_InputIterator __first, _InputIterator __last) 00128 : _M_t(_Compare(), _StorageTypeAlloc()) { 00129 # if defined (_STLP_USE_ITERATOR_WRAPPER) 00130 _M_t.insert_unique(typename _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__first), 00131 typename _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__last)); 00132 # else 00133 _M_t.insert_unique(__first, __last); 00134 # endif 00135 } 00136 00137 # if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) 00138 template <class _InputIterator> 00139 set(_InputIterator __first, _InputIterator __last, const _Compare& __comp) 00140 : _M_t(__comp, _StorageTypeAlloc()) { 00141 # if defined (_STLP_USE_ITERATOR_WRAPPER) 00142 _M_t.insert_unique(typename _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__first), 00143 typename _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__last)); 00144 # else 00145 _M_t.insert_unique(__first, __last); 00146 # endif 00147 } 00148 # endif 00149 template <class _InputIterator> 00150 set(_InputIterator __first, _InputIterator __last, const _Compare& __comp, 00151 const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) 00152 : _M_t(__comp, _STLP_CONVERT_ALLOCATOR(__a, _KeyStorageType)) { 00153 # if defined (_STLP_USE_ITERATOR_WRAPPER) 00154 _M_t.insert_unique(typename _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__first), 00155 typename _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__last)); 00156 # else 00157 _M_t.insert_unique(__first, __last); 00158 # endif 00159 } 00160 #else 00161 set(const value_type* __first, const value_type* __last) 00162 : _M_t(_Compare(), _StorageTypeAlloc()) { 00163 _M_t.insert_unique(cast_traits::to_storage_type_cptr(__first), 00164 cast_traits::to_storage_type_cptr(__last)); 00165 } 00166 00167 set(const value_type* __first, const value_type* __last, 00168 const _Compare& __comp, const allocator_type& __a = allocator_type()) 00169 : _M_t(__comp, _STLP_CONVERT_ALLOCATOR(__a, _KeyStorageType)) { 00170 _M_t.insert_unique(cast_traits::to_storage_type_cptr(__first), 00171 cast_traits::to_storage_type_cptr(__last)); 00172 } 00173 00174 set(const_iterator __first, const_iterator __last) 00175 : _M_t(_Compare(), _StorageTypeAlloc()) 00176 { _M_t.insert_unique(_S_to_storage_ite(__first), _S_to_storage_ite(__last)); } 00177 00178 set(const_iterator __first, const_iterator __last, 00179 const _Compare& __comp, const allocator_type& __a = allocator_type()) 00180 : _M_t(__comp, _STLP_CONVERT_ALLOCATOR(__a, _KeyStorageType)) 00181 { _M_t.insert_unique(_S_to_storage_ite(__first), _S_to_storage_ite(__last)); } 00182 #endif /* _STLP_MEMBER_TEMPLATES */ 00183 00184 set(const _Self& __x) : _M_t(__x._M_t) {} 00185 00186 set(__move_source<_Self> src) 00187 : _M_t(__move_source<_Rep_type>(src.get()._M_t)) {} 00188 00189 _Self& operator=(const _Self& __x) { 00190 _M_t = __x._M_t; 00191 return *this; 00192 } 00193 00194 // accessors: 00195 key_compare key_comp() const { return _M_t.key_comp(); } 00196 value_compare value_comp() const { return _M_t.key_comp(); } 00197 allocator_type get_allocator() const 00198 { return _STLP_CONVERT_ALLOCATOR(_M_t.get_allocator(), value_type); } 00199 00200 iterator begin() { return _S_to_value_ite(_M_t.begin()); } 00201 iterator end() { return _S_to_value_ite(_M_t.end()); } 00202 const_iterator begin() const { return _S_to_value_ite(_M_t.begin()); } 00203 const_iterator end() const { return _S_to_value_ite(_M_t.end()); } 00204 reverse_iterator rbegin() { return reverse_iterator(end()); } 00205 reverse_iterator rend() { return reverse_iterator(begin()); } 00206 const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } 00207 const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } 00208 bool empty() const { return _M_t.empty(); } 00209 size_type size() const { return _M_t.size(); } 00210 size_type max_size() const { return _M_t.max_size(); } 00211 void swap(_Self& __x) { _M_t.swap(__x._M_t); } 00212 00213 // insert/erase 00214 pair<iterator,bool> insert(const value_type& __x) { 00215 pair<base_iterator, bool> ret = _M_t.insert_unique(cast_traits::to_storage_type_cref(__x)); 00216 return pair<iterator, bool>(_S_to_value_ite(ret.first), ret.second); 00217 } 00218 iterator insert(iterator __pos, const value_type& __x) 00219 { return _S_to_value_ite(_M_t.insert_unique(_S_to_storage_ite(__pos), cast_traits::to_storage_type_cref(__x))); } 00220 00221 #if defined (_STLP_MEMBER_TEMPLATES) 00222 template <class _InputIterator> 00223 void insert(_InputIterator __first, _InputIterator __last) { 00224 # if defined (_STLP_USE_ITERATOR_WRAPPER) 00225 _M_t.insert_unique(typename _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__first), 00226 typename _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__last)); 00227 # else 00228 _M_t.insert_unique(__first, __last); 00229 # endif 00230 } 00231 #else 00232 void insert(const_iterator __first, const_iterator __last) 00233 { _M_t.insert_unique(_S_to_storage_ite(__first), _S_to_storage_ite(__last)); } 00234 void insert(const value_type* __first, const value_type* __last) { 00235 _M_t.insert_unique(cast_traits::to_storage_type_cptr(__first), 00236 cast_traits::to_storage_type_cptr(__last)); 00237 } 00238 #endif 00239 void erase(iterator __pos) 00240 { _M_t.erase(_S_to_storage_ite(__pos)); } 00241 size_type erase(const key_type& __x) 00242 { return _M_t.erase_unique(cast_traits::to_storage_type_cref(__x)); } 00243 void erase(iterator __first, iterator __last) 00244 { _M_t.erase(_S_to_storage_ite(__first), _S_to_storage_ite(__last)); } 00245 void clear() { _M_t.clear(); } 00246 00247 // set operations: 00248 _STLP_TEMPLATE_FOR_CONT_EXT 00249 const_iterator find(const _KT& __x) const 00250 { return _S_to_value_ite(_M_t.find(cast_traits::to_storage_type_crefT(__x))); } 00251 _STLP_TEMPLATE_FOR_CONT_EXT 00252 iterator find(const _KT& __x) 00253 { return _S_to_value_ite(_M_t.find(cast_traits::to_storage_type_crefT(__x))); } 00254 _STLP_TEMPLATE_FOR_CONT_EXT 00255 size_type count(const _KT& __x) const 00256 { return _M_t.find(cast_traits::to_storage_type_crefT(__x)) == _M_t.end() ? 0 : 1; } 00257 _STLP_TEMPLATE_FOR_CONT_EXT 00258 iterator lower_bound(const _KT& __x) 00259 { return _S_to_value_ite(_M_t.lower_bound(cast_traits::to_storage_type_crefT(__x))); } 00260 _STLP_TEMPLATE_FOR_CONT_EXT 00261 const_iterator lower_bound(const _KT& __x) const 00262 { return _S_to_value_ite(_M_t.lower_bound(cast_traits::to_storage_type_crefT(__x))); } 00263 _STLP_TEMPLATE_FOR_CONT_EXT 00264 iterator upper_bound(const _KT& __x) 00265 { return _S_to_value_ite(_M_t.upper_bound(cast_traits::to_storage_type_crefT(__x))); } 00266 _STLP_TEMPLATE_FOR_CONT_EXT 00267 const_iterator upper_bound(const _KT& __x) const 00268 { return _S_to_value_ite(_M_t.upper_bound(cast_traits::to_storage_type_crefT(__x))); } 00269 _STLP_TEMPLATE_FOR_CONT_EXT 00270 pair<iterator, iterator> equal_range(const _KT& __x) { 00271 pair<base_iterator, base_iterator> __ret; 00272 __ret = _M_t.equal_range(cast_traits::to_storage_type_crefT(__x)); 00273 return pair<iterator, iterator>(_S_to_value_ite(__ret.first), 00274 _S_to_value_ite(__ret.second)); 00275 } 00276 _STLP_TEMPLATE_FOR_CONT_EXT 00277 pair<const_iterator, const_iterator> equal_range(const _KT& __x) const { 00278 pair<const_base_iterator, const_base_iterator> __ret; 00279 __ret = _M_t.equal_range_unique(cast_traits::to_storage_type_crefT(__x)); 00280 return pair<const_iterator, const_iterator>(_S_to_value_ite(__ret.first), 00281 _S_to_value_ite(__ret.second)); 00282 } 00283 }; 00284 00285 //Specific iterator traits creation 00286 _STLP_CREATE_ITERATOR_TRAITS(MultisetTraitsT, Const_traits) 00287 00288 template <class _Key, _STLP_DFL_TMPL_PARAM(_Compare, less<_Key>), 00289 _STLP_DEFAULT_ALLOCATOR_SELECT(_Key) > 00290 class multiset 00291 #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) 00292 : public __stlport_class<multiset<_Key, _Compare, _Alloc> > 00293 #endif 00294 { 00295 typedef _STLP_PRIV _AssocStorageTypes<_Key, _Compare> _AssocStorageTypes; 00296 typedef typename _AssocStorageTypes::_KeyStorageType _KeyStorageType; 00297 typedef typename _AssocStorageTypes::_CompareStorageType _CompareStorageType; 00298 typedef typename _Alloc_traits<_KeyStorageType, _Alloc>::allocator_type _StorageTypeAlloc; 00299 typedef _STLP_PRIV _CastTraits<_KeyStorageType, _Key> cast_traits; 00300 00301 typedef multiset<_Key, _Compare, _Alloc> _Self; 00302 public: 00303 // typedefs: 00304 typedef _Key key_type; 00305 typedef _Key value_type; 00306 typedef _Compare key_compare; 00307 typedef _Compare value_compare; 00308 00309 protected: 00310 //Specific iterator traits creation 00311 typedef _STLP_PRIV _MultisetTraitsT<value_type> _MultisetTraits; 00312 typedef _STLP_PRIV _Rb_tree<key_type, key_compare, 00313 value_type, _STLP_PRIV _Identity<value_type>, 00314 _MultisetTraits, _Alloc> _Priv_Rep_type; 00315 00316 typedef _STLP_PRIV _MultisetTraitsT<_KeyStorageType> _MultisetStorageTraits; 00317 public: 00318 //dums: need the following public for the __move_traits framework 00319 typedef _STLP_PRIV _Rb_tree<_KeyStorageType, _CompareStorageType, 00320 _KeyStorageType, _STLP_PRIV _Identity<_KeyStorageType>, 00321 _MultisetStorageTraits, _StorageTypeAlloc> _Rep_type; 00322 00323 private: 00324 typedef typename _Rep_type::iterator base_iterator; 00325 typedef typename _Rep_type::const_iterator const_base_iterator; 00326 00327 public: 00328 typedef typename _Priv_Rep_type::pointer pointer; 00329 typedef typename _Priv_Rep_type::const_pointer const_pointer; 00330 typedef typename _Priv_Rep_type::reference reference; 00331 typedef typename _Priv_Rep_type::const_reference const_reference; 00332 typedef typename _Priv_Rep_type::iterator iterator; 00333 typedef typename _Priv_Rep_type::const_iterator const_iterator; 00334 typedef typename _Priv_Rep_type::reverse_iterator reverse_iterator; 00335 typedef typename _Priv_Rep_type::const_reverse_iterator const_reverse_iterator; 00336 typedef typename _Priv_Rep_type::size_type size_type; 00337 typedef typename _Priv_Rep_type::difference_type difference_type; 00338 typedef typename _Priv_Rep_type::allocator_type allocator_type; 00339 00340 private: 00341 _Rep_type _M_t; // red-black tree representing multiset 00342 _STLP_KEY_TYPE_FOR_CONT_EXT(key_type) 00343 00344 #if defined (_STLP_DEBUG) 00345 static iterator _S_to_value_ite(const_base_iterator __ite) 00346 { return iterator(__ite._Owner(), __ite._M_iterator._M_node); } 00347 static base_iterator _S_to_storage_ite(const_iterator __ite) 00348 { return base_iterator(__ite._Owner(), __ite._M_iterator._M_node); } 00349 #else 00350 static iterator _S_to_value_ite(const_base_iterator __ite) 00351 { return iterator(__ite._M_node); } 00352 static base_iterator _S_to_storage_ite(const_iterator __ite) 00353 { return base_iterator(__ite._M_node); } 00354 #endif 00355 00356 public: 00357 multiset() : _M_t(_Compare(), _StorageTypeAlloc()) {} 00358 explicit multiset(const _Compare& __comp, 00359 const allocator_type& __a = allocator_type()) 00360 : _M_t(__comp, _STLP_CONVERT_ALLOCATOR(__a, _KeyStorageType)) {} 00361 00362 #if defined (_STLP_MEMBER_TEMPLATES) 00363 template <class _InputIterator> 00364 multiset(_InputIterator __first, _InputIterator __last) 00365 : _M_t(_Compare(), _StorageTypeAlloc()) { 00366 # if defined (_STLP_USE_ITERATOR_WRAPPER) 00367 _M_t.insert_equal(typename _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__first), 00368 typename _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__last)); 00369 # else 00370 _M_t.insert_equal(__first, __last); 00371 # endif 00372 } 00373 00374 # if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) 00375 template <class _InputIterator> 00376 multiset(_InputIterator __first, _InputIterator __last, 00377 const _Compare& __comp) 00378 : _M_t(__comp, _StorageTypeAlloc()) { 00379 # if defined (_STLP_USE_ITERATOR_WRAPPER) 00380 _M_t.insert_equal(typename _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__first), 00381 typename _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__last)); 00382 # else 00383 _M_t.insert_equal(__first, __last); 00384 # endif 00385 } 00386 # endif 00387 template <class _InputIterator> 00388 multiset(_InputIterator __first, _InputIterator __last, 00389 const _Compare& __comp, 00390 const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) 00391 : _M_t(__comp, _STLP_CONVERT_ALLOCATOR(__a, _KeyStorageType)) { 00392 # if defined (_STLP_USE_ITERATOR_WRAPPER) 00393 _M_t.insert_equal(typename _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__first), 00394 typename _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__last)); 00395 # else 00396 _M_t.insert_equal(__first, __last); 00397 # endif 00398 } 00399 00400 #else 00401 multiset(const value_type* __first, const value_type* __last) 00402 : _M_t(_Compare(), _StorageTypeAlloc()) { 00403 _M_t.insert_equal(cast_traits::to_storage_type_cptr(__first), 00404 cast_traits::to_storage_type_cptr(__last)); 00405 } 00406 00407 multiset(const value_type* __first, const value_type* __last, 00408 const _Compare& __comp, 00409 const allocator_type& __a = allocator_type()) 00410 : _M_t(__comp, _STLP_CONVERT_ALLOCATOR(__a, _KeyStorageType)) { 00411 _M_t.insert_equal(cast_traits::to_storage_type_cptr(__first), 00412 cast_traits::to_storage_type_cptr(__last)); 00413 } 00414 00415 multiset(const_iterator __first, const_iterator __last) 00416 : _M_t(_Compare(), _StorageTypeAlloc()) 00417 { _M_t.insert_equal(_S_to_storage_ite(__first), _S_to_storage_ite(__last)); } 00418 00419 multiset(const_iterator __first, const_iterator __last, 00420 const _Compare& __comp, 00421 const allocator_type& __a = allocator_type()) 00422 : _M_t(__comp, _STLP_CONVERT_ALLOCATOR(__a, _KeyStorageType)) 00423 { _M_t.insert_equal(_S_to_storage_ite(__first), _S_to_storage_ite(__last)); } 00424 #endif /* _STLP_MEMBER_TEMPLATES */ 00425 00426 multiset(const _Self& __x) 00427 : _M_t(__x._M_t) {} 00428 00429 _Self& operator=(const _Self& __x) { 00430 _M_t = __x._M_t; 00431 return *this; 00432 } 00433 00434 multiset(__move_source<_Self> src) 00435 : _M_t(__move_source<_Rep_type>(src.get()._M_t)) {} 00436 00437 // accessors: 00438 key_compare key_comp() const { return _M_t.key_comp(); } 00439 value_compare value_comp() const { return _M_t.key_comp(); } 00440 allocator_type get_allocator() const 00441 { return _STLP_CONVERT_ALLOCATOR(_M_t.get_allocator(), value_type); } 00442 00443 iterator begin() { return _S_to_value_ite(_M_t.begin()); } 00444 iterator end() { return _S_to_value_ite(_M_t.end()); } 00445 const_iterator begin() const { return _S_to_value_ite(_M_t.begin()); } 00446 const_iterator end() const { return _S_to_value_ite(_M_t.end()); } 00447 reverse_iterator rbegin() { return reverse_iterator(end()); } 00448 reverse_iterator rend() { return reverse_iterator(begin()); } 00449 const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } 00450 const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } 00451 bool empty() const { return _M_t.empty(); } 00452 size_type size() const { return _M_t.size(); } 00453 size_type max_size() const { return _M_t.max_size(); } 00454 void swap(_Self& __x) { _M_t.swap(__x._M_t); } 00455 00456 // insert/erase 00457 iterator insert(const value_type& __x) 00458 { return _S_to_value_ite(_M_t.insert_equal(cast_traits::to_storage_type_cref(__x))); } 00459 iterator insert(iterator __pos, const value_type& __x) { 00460 return _S_to_value_ite(_M_t.insert_equal(_S_to_storage_ite(__pos), 00461 cast_traits::to_storage_type_cref(__x))); 00462 } 00463 00464 #if defined (_STLP_MEMBER_TEMPLATES) 00465 template <class _InputIterator> 00466 void insert(_InputIterator __first, _InputIterator __last) { 00467 # if defined (_STLP_USE_ITERATOR_WRAPPER) 00468 _M_t.insert_equal(typename _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__first), 00469 typename _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__last)); 00470 # else 00471 _M_t.insert_equal(__first, __last); 00472 # endif 00473 } 00474 #else 00475 void insert(const value_type* __first, const value_type* __last) { 00476 _M_t.insert_equal(cast_traits::to_storage_type_cptr(__first), 00477 cast_traits::to_storage_type_cptr(__last)); 00478 } 00479 void insert(const_iterator __first, const_iterator __last) 00480 { _M_t.insert_equal(_S_to_storage_ite(__first), _S_to_storage_ite(__last)); } 00481 #endif /* _STLP_MEMBER_TEMPLATES */ 00482 00483 void erase(iterator __pos) 00484 { _M_t.erase(_S_to_storage_ite(__pos)); } 00485 size_type erase(const key_type& __x) 00486 { return _M_t.erase(cast_traits::to_storage_type_cref(__x)); } 00487 void erase(iterator __first, iterator __last) 00488 { _M_t.erase(_S_to_storage_ite(__first), _S_to_storage_ite(__last)); } 00489 void clear() { _M_t.clear(); } 00490 00491 // multiset operations: 00492 00493 _STLP_TEMPLATE_FOR_CONT_EXT 00494 iterator find(const _KT& __x) 00495 { return _S_to_value_ite(_M_t.find(cast_traits::to_storage_type_crefT(__x))); } 00496 _STLP_TEMPLATE_FOR_CONT_EXT 00497 const_iterator find(const _KT& __x) const 00498 { return _S_to_value_ite(_M_t.find(cast_traits::to_storage_type_crefT(__x))); } 00499 _STLP_TEMPLATE_FOR_CONT_EXT 00500 size_type count(const _KT& __x) const 00501 { return _M_t.count(cast_traits::to_storage_type_crefT(__x)); } 00502 _STLP_TEMPLATE_FOR_CONT_EXT 00503 iterator lower_bound(const _KT& __x) 00504 { return _S_to_value_ite(_M_t.lower_bound(cast_traits::to_storage_type_crefT(__x))); } 00505 _STLP_TEMPLATE_FOR_CONT_EXT 00506 const_iterator lower_bound(const _KT& __x) const 00507 { return _S_to_value_ite(_M_t.lower_bound(cast_traits::to_storage_type_crefT(__x))); } 00508 _STLP_TEMPLATE_FOR_CONT_EXT 00509 iterator upper_bound(const _KT& __x) 00510 { return _S_to_value_ite(_M_t.upper_bound(cast_traits::to_storage_type_crefT(__x))); } 00511 _STLP_TEMPLATE_FOR_CONT_EXT 00512 const_iterator upper_bound(const _KT& __x) const 00513 { return _S_to_value_ite(_M_t.upper_bound(cast_traits::to_storage_type_crefT(__x))); } 00514 _STLP_TEMPLATE_FOR_CONT_EXT 00515 pair<iterator, iterator> equal_range(const _KT& __x) { 00516 pair<base_iterator, base_iterator> __ret; 00517 __ret = _M_t.equal_range(cast_traits::to_storage_type_crefT(__x)); 00518 return pair<iterator, iterator>(_S_to_value_ite(__ret.first), 00519 _S_to_value_ite(__ret.second)); 00520 } 00521 _STLP_TEMPLATE_FOR_CONT_EXT 00522 pair<const_iterator, const_iterator> equal_range(const _KT& __x) const { 00523 pair<const_base_iterator, const_base_iterator> __ret; 00524 __ret = _M_t.equal_range(cast_traits::to_storage_type_crefT(__x)); 00525 return pair<const_iterator, const_iterator>(_S_to_value_ite(__ret.first), 00526 _S_to_value_ite(__ret.second)); 00527 } 00528 }; 00529 00530 _STLP_END_NAMESPACE 00531 00532 #endif /* _STLP_PTR_SPECIALIZED_SET_H */ 00533 00534 // Local Variables: 00535 // mode:C++ 00536 // End:
Generated on Mon Mar 10 15:32:34 2008 by ![]() |