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