00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef _GLIBCXX_PROFILE_MULTISET_H
00030 #define _GLIBCXX_PROFILE_MULTISET_H 1
00031
00032 #include <utility>
00033
00034 namespace std
00035 {
00036 namespace __profile
00037 {
00038
00039 template<typename _Key, typename _Compare = std::less<_Key>,
00040 typename _Allocator = std::allocator<_Key> >
00041 class multiset
00042 : public _GLIBCXX_STD_D::multiset<_Key, _Compare, _Allocator>
00043 {
00044 typedef _GLIBCXX_STD_D::multiset<_Key, _Compare, _Allocator> _Base;
00045
00046 public:
00047
00048 typedef _Key key_type;
00049 typedef _Key value_type;
00050 typedef _Compare key_compare;
00051 typedef _Compare value_compare;
00052 typedef _Allocator allocator_type;
00053 typedef typename _Base::reference reference;
00054 typedef typename _Base::const_reference const_reference;
00055
00056 typedef typename _Base::iterator iterator;
00057 typedef typename _Base::const_iterator const_iterator;
00058 typedef typename _Base::reverse_iterator reverse_iterator;
00059 typedef typename _Base::const_reverse_iterator const_reverse_iterator;
00060
00061 typedef typename _Base::size_type size_type;
00062 typedef typename _Base::difference_type difference_type;
00063 typedef typename _Base::pointer pointer;
00064 typedef typename _Base::const_pointer const_pointer;
00065
00066
00067 explicit multiset(const _Compare& __comp = _Compare(),
00068 const _Allocator& __a = _Allocator())
00069 : _Base(__comp, __a) { }
00070
00071 template<typename _InputIterator>
00072 multiset(_InputIterator __first, _InputIterator __last,
00073 const _Compare& __comp = _Compare(),
00074 const _Allocator& __a = _Allocator())
00075 : _Base(__first, __last, __comp, __a) { }
00076
00077 multiset(const multiset& __x)
00078 : _Base(__x) { }
00079
00080 multiset(const _Base& __x)
00081 : _Base(__x) { }
00082
00083 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00084 multiset(multiset&& __x)
00085 : _Base(std::forward<multiset>(__x))
00086 { }
00087
00088 multiset(initializer_list<value_type> __l,
00089 const _Compare& __comp = _Compare(),
00090 const allocator_type& __a = allocator_type())
00091 : _Base(__l, __comp, __a) { }
00092 #endif
00093
00094 ~multiset() { }
00095
00096 multiset&
00097 operator=(const multiset& __x)
00098 {
00099 *static_cast<_Base*>(this) = __x;
00100 return *this;
00101 }
00102
00103 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00104 multiset&
00105 operator=(multiset&& __x)
00106 {
00107
00108
00109 this->clear();
00110 this->swap(__x);
00111 return *this;
00112 }
00113
00114 multiset&
00115 operator=(initializer_list<value_type> __l)
00116 {
00117 this->clear();
00118 this->insert(__l);
00119 return *this;
00120 }
00121 #endif
00122
00123 using _Base::get_allocator;
00124
00125
00126 iterator
00127 begin()
00128 { return iterator(_Base::begin()); }
00129
00130 const_iterator
00131 begin() const
00132 { return const_iterator(_Base::begin()); }
00133
00134 iterator
00135 end()
00136 { return iterator(_Base::end()); }
00137
00138 const_iterator
00139 end() const
00140 { return const_iterator(_Base::end()); }
00141
00142 reverse_iterator
00143 rbegin()
00144 { return reverse_iterator(end()); }
00145
00146 const_reverse_iterator
00147 rbegin() const
00148 { return const_reverse_iterator(end()); }
00149
00150 reverse_iterator
00151 rend()
00152 { return reverse_iterator(begin()); }
00153
00154 const_reverse_iterator
00155 rend() const
00156 { return const_reverse_iterator(begin()); }
00157
00158 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00159 const_iterator
00160 cbegin() const
00161 { return const_iterator(_Base::begin()); }
00162
00163 const_iterator
00164 cend() const
00165 { return const_iterator(_Base::end()); }
00166
00167 const_reverse_iterator
00168 crbegin() const
00169 { return const_reverse_iterator(end()); }
00170
00171 const_reverse_iterator
00172 crend() const
00173 { return const_reverse_iterator(begin()); }
00174 #endif
00175
00176
00177 using _Base::empty;
00178 using _Base::size;
00179 using _Base::max_size;
00180
00181
00182 iterator
00183 insert(const value_type& __x)
00184 { return iterator(_Base::insert(__x)); }
00185
00186 iterator
00187 insert(iterator __position, const value_type& __x)
00188 {
00189 return iterator(_Base::insert(__position, __x));
00190 }
00191
00192 template<typename _InputIterator>
00193 void
00194 insert(_InputIterator __first, _InputIterator __last)
00195 {
00196 _Base::insert(__first, __last);
00197 }
00198
00199 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00200 void
00201 insert(initializer_list<value_type> __l)
00202 { _Base::insert(__l); }
00203 #endif
00204
00205 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00206 iterator
00207 erase(iterator __position)
00208 { return _Base::erase(__position); }
00209 #else
00210 void
00211 erase(iterator __position)
00212 { _Base::erase(__position); }
00213 #endif
00214
00215 size_type
00216 erase(const key_type& __x)
00217 {
00218 std::pair<iterator, iterator> __victims = this->equal_range(__x);
00219 size_type __count = 0;
00220 while (__victims.first != __victims.second)
00221 {
00222 iterator __victim = __victims.first++;
00223 _Base::erase(__victim);
00224 ++__count;
00225 }
00226 return __count;
00227 }
00228
00229 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00230 iterator
00231 erase(iterator __first, iterator __last)
00232 {
00233
00234
00235 while (__first != __last)
00236 this->erase(__first++);
00237 return __last;
00238 }
00239 #else
00240 void
00241 erase(iterator __first, iterator __last)
00242 {
00243
00244
00245 while (__first != __last)
00246 this->erase(__first++);
00247 }
00248 #endif
00249
00250 void
00251 swap(multiset& __x)
00252 {
00253 _Base::swap(__x);
00254 }
00255
00256 void
00257 clear()
00258 { this->erase(begin(), end()); }
00259
00260
00261 using _Base::key_comp;
00262 using _Base::value_comp;
00263
00264
00265 iterator
00266 find(const key_type& __x)
00267 { return iterator(_Base::find(__x)); }
00268
00269
00270
00271 const_iterator
00272 find(const key_type& __x) const
00273 { return const_iterator(_Base::find(__x)); }
00274
00275 using _Base::count;
00276
00277 iterator
00278 lower_bound(const key_type& __x)
00279 { return iterator(_Base::lower_bound(__x)); }
00280
00281
00282
00283 const_iterator
00284 lower_bound(const key_type& __x) const
00285 { return const_iterator(_Base::lower_bound(__x)); }
00286
00287 iterator
00288 upper_bound(const key_type& __x)
00289 { return iterator(_Base::upper_bound(__x)); }
00290
00291
00292
00293 const_iterator
00294 upper_bound(const key_type& __x) const
00295 { return const_iterator(_Base::upper_bound(__x)); }
00296
00297 std::pair<iterator,iterator>
00298 equal_range(const key_type& __x)
00299 {
00300 typedef typename _Base::iterator _Base_iterator;
00301 std::pair<_Base_iterator, _Base_iterator> __res =
00302 _Base::equal_range(__x);
00303 return std::make_pair(iterator(__res.first),
00304 iterator(__res.second));
00305 }
00306
00307
00308
00309 std::pair<const_iterator,const_iterator>
00310 equal_range(const key_type& __x) const
00311 {
00312 typedef typename _Base::const_iterator _Base_iterator;
00313 std::pair<_Base_iterator, _Base_iterator> __res =
00314 _Base::equal_range(__x);
00315 return std::make_pair(const_iterator(__res.first),
00316 const_iterator(__res.second));
00317 }
00318
00319 _Base&
00320 _M_base() { return *this; }
00321
00322 const _Base&
00323 _M_base() const { return *this; }
00324
00325 };
00326
00327 template<typename _Key, typename _Compare, typename _Allocator>
00328 inline bool
00329 operator==(const multiset<_Key, _Compare, _Allocator>& __lhs,
00330 const multiset<_Key, _Compare, _Allocator>& __rhs)
00331 { return __lhs._M_base() == __rhs._M_base(); }
00332
00333 template<typename _Key, typename _Compare, typename _Allocator>
00334 inline bool
00335 operator!=(const multiset<_Key, _Compare, _Allocator>& __lhs,
00336 const multiset<_Key, _Compare, _Allocator>& __rhs)
00337 { return __lhs._M_base() != __rhs._M_base(); }
00338
00339 template<typename _Key, typename _Compare, typename _Allocator>
00340 inline bool
00341 operator<(const multiset<_Key, _Compare, _Allocator>& __lhs,
00342 const multiset<_Key, _Compare, _Allocator>& __rhs)
00343 { return __lhs._M_base() < __rhs._M_base(); }
00344
00345 template<typename _Key, typename _Compare, typename _Allocator>
00346 inline bool
00347 operator<=(const multiset<_Key, _Compare, _Allocator>& __lhs,
00348 const multiset<_Key, _Compare, _Allocator>& __rhs)
00349 { return __lhs._M_base() <= __rhs._M_base(); }
00350
00351 template<typename _Key, typename _Compare, typename _Allocator>
00352 inline bool
00353 operator>=(const multiset<_Key, _Compare, _Allocator>& __lhs,
00354 const multiset<_Key, _Compare, _Allocator>& __rhs)
00355 { return __lhs._M_base() >= __rhs._M_base(); }
00356
00357 template<typename _Key, typename _Compare, typename _Allocator>
00358 inline bool
00359 operator>(const multiset<_Key, _Compare, _Allocator>& __lhs,
00360 const multiset<_Key, _Compare, _Allocator>& __rhs)
00361 { return __lhs._M_base() > __rhs._M_base(); }
00362
00363 template<typename _Key, typename _Compare, typename _Allocator>
00364 void
00365 swap(multiset<_Key, _Compare, _Allocator>& __x,
00366 multiset<_Key, _Compare, _Allocator>& __y)
00367 { return __x.swap(__y); }
00368
00369 }
00370 }
00371
00372 #endif