Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygen_set.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_SET_H 00031 #define _STLP_INTERNAL_SET_H 00032 00033 #ifndef _STLP_INTERNAL_TREE_H 00034 # include <stl/_tree.h> 00035 #endif 00036 00037 #if !defined (_STLP_USE_PTR_SPECIALIZATIONS) 00038 00039 _STLP_BEGIN_NAMESPACE 00040 00041 //Specific iterator traits creation 00042 _STLP_CREATE_ITERATOR_TRAITS(SetTraitsT, Const_traits) 00043 00044 template <class _Key, _STLP_DFL_TMPL_PARAM(_Compare, less<_Key>), 00045 _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Key>) > 00046 class set 00047 #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) 00048 : public __stlport_class<set<_Key, _Compare, _Alloc> > 00049 #endif 00050 { 00051 typedef set<_Key, _Compare, _Alloc> _Self; 00052 public: 00053 // typedefs: 00054 typedef _Key key_type; 00055 typedef _Key value_type; 00056 typedef _Compare key_compare; 00057 typedef _Compare value_compare; 00058 00059 private: 00060 //Specific iterator traits creation 00061 typedef _STLP_PRIV _SetTraitsT<value_type> _SetTraits; 00062 00063 public: 00064 //Following typedef have to be public for __move_traits specialization. 00065 typedef _STLP_PRIV _Rb_tree<key_type, key_compare, 00066 value_type, _STLP_PRIV _Identity<value_type>, 00067 _SetTraits, _Alloc> _Rep_type; 00068 00069 typedef typename _Rep_type::pointer pointer; 00070 typedef typename _Rep_type::const_pointer const_pointer; 00071 typedef typename _Rep_type::reference reference; 00072 typedef typename _Rep_type::const_reference const_reference; 00073 typedef typename _Rep_type::iterator iterator; 00074 typedef typename _Rep_type::const_iterator const_iterator; 00075 typedef typename _Rep_type::reverse_iterator reverse_iterator; 00076 typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; 00077 typedef typename _Rep_type::size_type size_type; 00078 typedef typename _Rep_type::difference_type difference_type; 00079 typedef typename _Rep_type::allocator_type allocator_type; 00080 00081 private: 00082 _Rep_type _M_t; // red-black tree representing set 00083 _STLP_KEY_TYPE_FOR_CONT_EXT(key_type) 00084 00085 public: 00086 00087 // allocation/deallocation 00088 #if !defined (_STLP_DONT_SUP_DFLT_PARAM) 00089 explicit set(const _Compare& __comp = _Compare(), 00090 const allocator_type& __a = allocator_type()) 00091 #else 00092 set() 00093 : _M_t(_Compare(), allocator_type()) {} 00094 explicit set(const _Compare& __comp) 00095 : _M_t(__comp, allocator_type()) {} 00096 set(const _Compare& __comp, const allocator_type& __a) 00097 #endif 00098 : _M_t(__comp, __a) {} 00099 00100 #if defined (_STLP_MEMBER_TEMPLATES) 00101 template <class _InputIterator> 00102 set(_InputIterator __first, _InputIterator __last) 00103 : _M_t(_Compare(), allocator_type()) 00104 { _M_t.insert_unique(__first, __last); } 00105 00106 # if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) 00107 template <class _InputIterator> 00108 set(_InputIterator __first, _InputIterator __last, const _Compare& __comp) 00109 : _M_t(__comp, allocator_type()) { _M_t.insert_unique(__first, __last); } 00110 # endif 00111 template <class _InputIterator> 00112 set(_InputIterator __first, _InputIterator __last, const _Compare& __comp, 00113 const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) 00114 : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); } 00115 #else 00116 set(const value_type* __first, const value_type* __last) 00117 : _M_t(_Compare(), allocator_type()) 00118 { _M_t.insert_unique(__first, __last); } 00119 00120 set(const value_type* __first, 00121 const value_type* __last, const _Compare& __comp, 00122 const allocator_type& __a = allocator_type()) 00123 : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); } 00124 00125 set(const_iterator __first, const_iterator __last) 00126 : _M_t(_Compare(), allocator_type()) 00127 { _M_t.insert_unique(__first, __last); } 00128 00129 set(const_iterator __first, const_iterator __last, const _Compare& __comp, 00130 const allocator_type& __a = allocator_type()) 00131 : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); } 00132 #endif /* _STLP_MEMBER_TEMPLATES */ 00133 00134 set(const _Self& __x) : _M_t(__x._M_t) {} 00135 00136 #if !defined (_STLP_NO_MOVE_SEMANTIC) 00137 set(__move_source<_Self> src) 00138 : _M_t(__move_source<_Rep_type>(src.get()._M_t)) {} 00139 #endif 00140 00141 _Self& operator=(const _Self& __x) { 00142 _M_t = __x._M_t; 00143 return *this; 00144 } 00145 00146 // accessors: 00147 key_compare key_comp() const { return _M_t.key_comp(); } 00148 value_compare value_comp() const { return _M_t.key_comp(); } 00149 allocator_type get_allocator() const { return _M_t.get_allocator(); } 00150 00151 iterator begin() { return _M_t.begin(); } 00152 iterator end() { return _M_t.end(); } 00153 const_iterator begin() const { return _M_t.begin(); } 00154 const_iterator end() const { return _M_t.end(); } 00155 reverse_iterator rbegin() { return _M_t.rbegin(); } 00156 reverse_iterator rend() { return _M_t.rend(); } 00157 const_reverse_iterator rbegin() const { return _M_t.rbegin(); } 00158 const_reverse_iterator rend() const { return _M_t.rend(); } 00159 bool empty() const { return _M_t.empty(); } 00160 size_type size() const { return _M_t.size(); } 00161 size_type max_size() const { return _M_t.max_size(); } 00162 void swap(_Self& __x) { _M_t.swap(__x._M_t); } 00163 #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) 00164 void _M_swap_workaround(_Self& __x) { swap(__x); } 00165 #endif 00166 00167 // insert/erase 00168 pair<iterator,bool> insert(const value_type& __x) 00169 { return _M_t.insert_unique(__x); } 00170 iterator insert(iterator __pos, const value_type& __x) 00171 { return _M_t.insert_unique( __pos , __x); } 00172 #if defined (_STLP_MEMBER_TEMPLATES) 00173 template <class _InputIterator> 00174 void insert(_InputIterator __first, _InputIterator __last) 00175 { _M_t.insert_unique(__first, __last); } 00176 #else 00177 void insert(const_iterator __first, const_iterator __last) 00178 { _M_t.insert_unique(__first, __last); } 00179 void insert(const value_type* __first, const value_type* __last) 00180 { _M_t.insert_unique(__first, __last); } 00181 #endif /* _STLP_MEMBER_TEMPLATES */ 00182 void erase(iterator __pos) { _M_t.erase( __pos ); } 00183 size_type erase(const key_type& __x) { return _M_t.erase_unique(__x); } 00184 void erase(iterator __first, iterator __last) { _M_t.erase(__first, __last ); } 00185 void clear() { _M_t.clear(); } 00186 00187 // set operations: 00188 _STLP_TEMPLATE_FOR_CONT_EXT 00189 const_iterator find(const _KT& __x) const { return _M_t.find(__x); } 00190 _STLP_TEMPLATE_FOR_CONT_EXT 00191 iterator find(const _KT& __x) { return _M_t.find(__x); } 00192 _STLP_TEMPLATE_FOR_CONT_EXT 00193 size_type count(const _KT& __x) const 00194 { return _M_t.find(__x) == _M_t.end() ? 0 : 1 ; } 00195 _STLP_TEMPLATE_FOR_CONT_EXT 00196 iterator lower_bound(const _KT& __x) { return _M_t.lower_bound(__x); } 00197 _STLP_TEMPLATE_FOR_CONT_EXT 00198 const_iterator lower_bound(const _KT& __x) const { return _M_t.lower_bound(__x); } 00199 _STLP_TEMPLATE_FOR_CONT_EXT 00200 iterator upper_bound(const _KT& __x) { return _M_t.upper_bound(__x); } 00201 _STLP_TEMPLATE_FOR_CONT_EXT 00202 const_iterator upper_bound(const _KT& __x) const { return _M_t.upper_bound(__x); } 00203 _STLP_TEMPLATE_FOR_CONT_EXT 00204 pair<iterator, iterator> equal_range(const _KT& __x) 00205 { return _M_t.equal_range_unique(__x); } 00206 _STLP_TEMPLATE_FOR_CONT_EXT 00207 pair<const_iterator, const_iterator> equal_range(const _KT& __x) const 00208 { return _M_t.equal_range_unique(__x); } 00209 }; 00210 00211 //Specific iterator traits creation 00212 _STLP_CREATE_ITERATOR_TRAITS(MultisetTraitsT, Const_traits) 00213 00214 template <class _Key, _STLP_DFL_TMPL_PARAM(_Compare, less<_Key>), 00215 _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Key>) > 00216 class multiset 00217 #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) 00218 : public __stlport_class<multiset<_Key, _Compare, _Alloc> > 00219 #endif 00220 { 00221 typedef multiset<_Key, _Compare, _Alloc> _Self; 00222 public: 00223 // typedefs: 00224 00225 typedef _Key key_type; 00226 typedef _Key value_type; 00227 typedef _Compare key_compare; 00228 typedef _Compare value_compare; 00229 00230 private: 00231 //Specific iterator traits creation 00232 typedef _STLP_PRIV _MultisetTraitsT<value_type> _MultisetTraits; 00233 00234 public: 00235 //Following typedef have to be public for __move_traits specialization. 00236 typedef _STLP_PRIV _Rb_tree<key_type, key_compare, 00237 value_type, _STLP_PRIV _Identity<value_type>, 00238 _MultisetTraits, _Alloc> _Rep_type; 00239 00240 typedef typename _Rep_type::pointer pointer; 00241 typedef typename _Rep_type::const_pointer const_pointer; 00242 typedef typename _Rep_type::reference reference; 00243 typedef typename _Rep_type::const_reference const_reference; 00244 typedef typename _Rep_type::iterator iterator; 00245 typedef typename _Rep_type::const_iterator const_iterator; 00246 typedef typename _Rep_type::reverse_iterator reverse_iterator; 00247 typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator; 00248 typedef typename _Rep_type::size_type size_type; 00249 typedef typename _Rep_type::difference_type difference_type; 00250 typedef typename _Rep_type::allocator_type allocator_type; 00251 00252 private: 00253 _Rep_type _M_t; // red-black tree representing multiset 00254 _STLP_KEY_TYPE_FOR_CONT_EXT(key_type) 00255 00256 public: 00257 #if !defined (_STLP_DONT_SUP_DFLT_PARAM) 00258 explicit multiset(const _Compare& __comp = _Compare(), 00259 const allocator_type& __a = allocator_type()) 00260 #else 00261 multiset() 00262 : _M_t(_Compare(), allocator_type()) {} 00263 explicit multiset(const _Compare& __comp) 00264 : _M_t(__comp, allocator_type()) {} 00265 multiset(const _Compare& __comp, const allocator_type& __a) 00266 #endif 00267 : _M_t(__comp, __a) {} 00268 00269 #if defined (_STLP_MEMBER_TEMPLATES) 00270 template <class _InputIterator> 00271 multiset(_InputIterator __first, _InputIterator __last) 00272 : _M_t(_Compare(), allocator_type()) 00273 { _M_t.insert_equal(__first, __last); } 00274 00275 template <class _InputIterator> 00276 multiset(_InputIterator __first, _InputIterator __last, 00277 const _Compare& __comp, 00278 const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) 00279 : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } 00280 # if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) 00281 template <class _InputIterator> 00282 multiset(_InputIterator __first, _InputIterator __last, 00283 const _Compare& __comp) 00284 : _M_t(__comp, allocator_type()) { _M_t.insert_equal(__first, __last); } 00285 # endif 00286 #else 00287 multiset(const value_type* __first, const value_type* __last) 00288 : _M_t(_Compare(), allocator_type()) 00289 { _M_t.insert_equal(__first, __last); } 00290 00291 multiset(const value_type* __first, const value_type* __last, 00292 const _Compare& __comp, 00293 const allocator_type& __a = allocator_type()) 00294 : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } 00295 00296 multiset(const_iterator __first, const_iterator __last) 00297 : _M_t(_Compare(), allocator_type()) 00298 { _M_t.insert_equal(__first, __last); } 00299 00300 multiset(const_iterator __first, const_iterator __last, 00301 const _Compare& __comp, 00302 const allocator_type& __a = allocator_type()) 00303 : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } 00304 #endif /* _STLP_MEMBER_TEMPLATES */ 00305 00306 multiset(const _Self& __x) : _M_t(__x._M_t) {} 00307 _Self& operator=(const _Self& __x) { 00308 _M_t = __x._M_t; 00309 return *this; 00310 } 00311 00312 #if !defined (_STLP_NO_MOVE_SEMANTIC) 00313 multiset(__move_source<_Self> src) 00314 : _M_t(__move_source<_Rep_type>(src.get()._M_t)) {} 00315 #endif 00316 00317 // accessors: 00318 key_compare key_comp() const { return _M_t.key_comp(); } 00319 value_compare value_comp() const { return _M_t.key_comp(); } 00320 allocator_type get_allocator() const { return _M_t.get_allocator(); } 00321 00322 iterator begin() { return _M_t.begin(); } 00323 iterator end() { return _M_t.end(); } 00324 const_iterator begin() const { return _M_t.begin(); } 00325 const_iterator end() const { return _M_t.end(); } 00326 reverse_iterator rbegin() { return _M_t.rbegin(); } 00327 reverse_iterator rend() { return _M_t.rend(); } 00328 const_reverse_iterator rbegin() const { return _M_t.rbegin(); } 00329 const_reverse_iterator rend() const { return _M_t.rend(); } 00330 bool empty() const { return _M_t.empty(); } 00331 size_type size() const { return _M_t.size(); } 00332 size_type max_size() const { return _M_t.max_size(); } 00333 void swap(_Self& __x) { _M_t.swap(__x._M_t); } 00334 #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) 00335 void _M_swap_workaround(_Self& __x) { swap(__x); } 00336 #endif 00337 00338 // insert/erase 00339 iterator insert(const value_type& __x) 00340 { return _M_t.insert_equal(__x); } 00341 iterator insert(iterator __pos, const value_type& __x) 00342 { return _M_t.insert_equal(__pos, __x); } 00343 00344 #if defined (_STLP_MEMBER_TEMPLATES) 00345 template <class _InputIterator> 00346 void insert(_InputIterator __first, _InputIterator __last) 00347 { _M_t.insert_equal(__first, __last); } 00348 #else 00349 void insert(const value_type* __first, const value_type* __last) 00350 { _M_t.insert_equal(__first, __last); } 00351 void insert(const_iterator __first, const_iterator __last) 00352 { _M_t.insert_equal(__first, __last); } 00353 #endif /* _STLP_MEMBER_TEMPLATES */ 00354 void erase(iterator __pos) { _M_t.erase( __pos ); } 00355 size_type erase(const key_type& __x) { return _M_t.erase(__x); } 00356 void erase(iterator __first, iterator __last) { _M_t.erase( __first, __last ); } 00357 void clear() { _M_t.clear(); } 00358 00359 // multiset operations: 00360 _STLP_TEMPLATE_FOR_CONT_EXT 00361 iterator find(const _KT& __x) { return _M_t.find(__x); } 00362 _STLP_TEMPLATE_FOR_CONT_EXT 00363 const_iterator find(const _KT& __x) const { return _M_t.find(__x); } 00364 _STLP_TEMPLATE_FOR_CONT_EXT 00365 size_type count(const _KT& __x) const { return _M_t.count(__x); } 00366 _STLP_TEMPLATE_FOR_CONT_EXT 00367 iterator lower_bound(const _KT& __x) { return _M_t.lower_bound(__x); } 00368 _STLP_TEMPLATE_FOR_CONT_EXT 00369 const_iterator lower_bound(const _KT& __x) const { return _M_t.lower_bound(__x); } 00370 _STLP_TEMPLATE_FOR_CONT_EXT 00371 iterator upper_bound(const _KT& __x) { return _M_t.upper_bound(__x); } 00372 _STLP_TEMPLATE_FOR_CONT_EXT 00373 const_iterator upper_bound(const _KT& __x) const { return _M_t.upper_bound(__x); } 00374 _STLP_TEMPLATE_FOR_CONT_EXT 00375 pair<iterator, iterator> equal_range(const _KT& __x) { return _M_t.equal_range(__x); } 00376 _STLP_TEMPLATE_FOR_CONT_EXT 00377 pair<const_iterator, const_iterator> equal_range(const _KT& __x) const { return _M_t.equal_range(__x); } 00378 }; 00379 00380 #else 00381 # include <stl/pointers/_set.h> 00382 _STLP_BEGIN_NAMESPACE 00383 #endif /* _STLP_USE_PTR_SPECIALIZATIONS */ 00384 00385 #define _STLP_TEMPLATE_HEADER template <class _Key, class _Compare, class _Alloc> 00386 #define _STLP_TEMPLATE_CONTAINER set<_Key,_Compare,_Alloc> 00387 #include <stl/_relops_cont.h> 00388 #undef _STLP_TEMPLATE_CONTAINER 00389 #define _STLP_TEMPLATE_CONTAINER multiset<_Key,_Compare,_Alloc> 00390 #include <stl/_relops_cont.h> 00391 #undef _STLP_TEMPLATE_CONTAINER 00392 #undef _STLP_TEMPLATE_HEADER 00393 00394 #if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_NO_MOVE_SEMANTIC) 00395 template <class _Key, class _Compare, class _Alloc> 00396 struct __move_traits<set<_Key,_Compare,_Alloc> > : 00397 _STLP_PRIV __move_traits_aux<typename set<_Key,_Compare,_Alloc>::_Rep_type> 00398 {}; 00399 00400 template <class _Key, class _Compare, class _Alloc> 00401 struct __move_traits<multiset<_Key,_Compare,_Alloc> > : 00402 _STLP_PRIV __move_traits_aux<typename multiset<_Key,_Compare,_Alloc>::_Rep_type> 00403 {}; 00404 #endif 00405 00406 _STLP_END_NAMESPACE 00407 00408 #endif /* _STLP_INTERNAL_SET_H */ 00409 00410 // Local Variables: 00411 // mode:C++ 00412 // End: Generated on Sun May 27 2012 04:29:24 for ReactOS by
1.7.6.1
|