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
00030
00031 #ifndef __SGI_STL_INTERNAL_MULTIMAP_H
00032 #define __SGI_STL_INTERNAL_MULTIMAP_H
00033
00034 #include <concept_checks.h>
00035
00036 __STL_BEGIN_NAMESPACE
00037
00038 #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
00039 #pragma set woff 1174
00040 #pragma set woff 1375
00041 #endif
00042
00043
00044
00045 template <class _Key, class _Tp,
00046 class _Compare __STL_DEPENDENT_DEFAULT_TMPL(less<_Key>),
00047 class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) >
00048 class multimap;
00049
00050 template <class _Key, class _Tp, class _Compare, class _Alloc>
00051 inline bool operator==(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
00052 const multimap<_Key,_Tp,_Compare,_Alloc>& __y);
00053
00054 template <class _Key, class _Tp, class _Compare, class _Alloc>
00055 inline bool operator<(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
00056 const multimap<_Key,_Tp,_Compare,_Alloc>& __y);
00057
00058 template <class _Key, class _Tp, class _Compare, class _Alloc>
00059 class multimap {
00060
00061
00062 __STL_CLASS_REQUIRES(_Tp, _Assignable);
00063 __STL_CLASS_BINARY_FUNCTION_CHECK(_Compare, bool, _Key, _Key);
00064
00065 public:
00066
00067
00068
00069 typedef _Key key_type;
00070 typedef _Tp data_type;
00071 typedef _Tp mapped_type;
00072 typedef pair<const _Key, _Tp> value_type;
00073 typedef _Compare key_compare;
00074
00075 class value_compare : public binary_function<value_type, value_type, bool> {
00076 friend class multimap<_Key,_Tp,_Compare,_Alloc>;
00077 protected:
00078 _Compare comp;
00079 value_compare(_Compare __c) : comp(__c) {}
00080 public:
00081 bool operator()(const value_type& __x, const value_type& __y) const {
00082 return comp(__x.first, __y.first);
00083 }
00084 };
00085
00086 private:
00087 typedef _Rb_tree<key_type, value_type,
00088 _Select1st<value_type>, key_compare, _Alloc> _Rep_type;
00089 _Rep_type _M_t;
00090 public:
00091 typedef typename _Rep_type::pointer pointer;
00092 typedef typename _Rep_type::const_pointer const_pointer;
00093 typedef typename _Rep_type::reference reference;
00094 typedef typename _Rep_type::const_reference const_reference;
00095 typedef typename _Rep_type::iterator iterator;
00096 typedef typename _Rep_type::const_iterator const_iterator;
00097 typedef typename _Rep_type::reverse_iterator reverse_iterator;
00098 typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
00099 typedef typename _Rep_type::size_type size_type;
00100 typedef typename _Rep_type::difference_type difference_type;
00101 typedef typename _Rep_type::allocator_type allocator_type;
00102
00103
00104
00105 multimap() : _M_t(_Compare(), allocator_type()) { }
00106 explicit multimap(const _Compare& __comp,
00107 const allocator_type& __a = allocator_type())
00108 : _M_t(__comp, __a) { }
00109
00110 #ifdef __STL_MEMBER_TEMPLATES
00111 template <class _InputIterator>
00112 multimap(_InputIterator __first, _InputIterator __last)
00113 : _M_t(_Compare(), allocator_type())
00114 { _M_t.insert_equal(__first, __last); }
00115
00116 template <class _InputIterator>
00117 multimap(_InputIterator __first, _InputIterator __last,
00118 const _Compare& __comp,
00119 const allocator_type& __a = allocator_type())
00120 : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); }
00121 #else
00122 multimap(const value_type* __first, const value_type* __last)
00123 : _M_t(_Compare(), allocator_type())
00124 { _M_t.insert_equal(__first, __last); }
00125 multimap(const value_type* __first, const value_type* __last,
00126 const _Compare& __comp,
00127 const allocator_type& __a = allocator_type())
00128 : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); }
00129
00130 multimap(const_iterator __first, const_iterator __last)
00131 : _M_t(_Compare(), allocator_type())
00132 { _M_t.insert_equal(__first, __last); }
00133 multimap(const_iterator __first, const_iterator __last,
00134 const _Compare& __comp,
00135 const allocator_type& __a = allocator_type())
00136 : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); }
00137 #endif
00138
00139 multimap(const multimap<_Key,_Tp,_Compare,_Alloc>& __x) : _M_t(__x._M_t) { }
00140 multimap<_Key,_Tp,_Compare,_Alloc>&
00141 operator=(const multimap<_Key,_Tp,_Compare,_Alloc>& __x) {
00142 _M_t = __x._M_t;
00143 return *this;
00144 }
00145
00146
00147
00148 key_compare key_comp() const { return _M_t.key_comp(); }
00149 value_compare value_comp() const { return value_compare(_M_t.key_comp()); }
00150 allocator_type get_allocator() const { return _M_t.get_allocator(); }
00151
00152 iterator begin() { return _M_t.begin(); }
00153 const_iterator begin() const { return _M_t.begin(); }
00154 iterator end() { return _M_t.end(); }
00155 const_iterator end() const { return _M_t.end(); }
00156 reverse_iterator rbegin() { return _M_t.rbegin(); }
00157 const_reverse_iterator rbegin() const { return _M_t.rbegin(); }
00158 reverse_iterator rend() { return _M_t.rend(); }
00159 const_reverse_iterator rend() const { return _M_t.rend(); }
00160 bool empty() const { return _M_t.empty(); }
00161 size_type size() const { return _M_t.size(); }
00162 size_type max_size() const { return _M_t.max_size(); }
00163 void swap(multimap<_Key,_Tp,_Compare,_Alloc>& __x) { _M_t.swap(__x._M_t); }
00164
00165
00166
00167 iterator insert(const value_type& __x) { return _M_t.insert_equal(__x); }
00168 iterator insert(iterator __position, const value_type& __x) {
00169 return _M_t.insert_equal(__position, __x);
00170 }
00171 #ifdef __STL_MEMBER_TEMPLATES
00172 template <class _InputIterator>
00173 void insert(_InputIterator __first, _InputIterator __last) {
00174 _M_t.insert_equal(__first, __last);
00175 }
00176 #else
00177 void insert(const value_type* __first, const value_type* __last) {
00178 _M_t.insert_equal(__first, __last);
00179 }
00180 void insert(const_iterator __first, const_iterator __last) {
00181 _M_t.insert_equal(__first, __last);
00182 }
00183 #endif
00184 void erase(iterator __position) { _M_t.erase(__position); }
00185 size_type erase(const key_type& __x) { return _M_t.erase(__x); }
00186 void erase(iterator __first, iterator __last)
00187 { _M_t.erase(__first, __last); }
00188 void clear() { _M_t.clear(); }
00189
00190
00191
00192 iterator find(const key_type& __x) { return _M_t.find(__x); }
00193 const_iterator find(const key_type& __x) const { return _M_t.find(__x); }
00194 size_type count(const key_type& __x) const { return _M_t.count(__x); }
00195 iterator lower_bound(const key_type& __x) {return _M_t.lower_bound(__x); }
00196 const_iterator lower_bound(const key_type& __x) const {
00197 return _M_t.lower_bound(__x);
00198 }
00199 iterator upper_bound(const key_type& __x) {return _M_t.upper_bound(__x); }
00200 const_iterator upper_bound(const key_type& __x) const {
00201 return _M_t.upper_bound(__x);
00202 }
00203 pair<iterator,iterator> equal_range(const key_type& __x) {
00204 return _M_t.equal_range(__x);
00205 }
00206 pair<const_iterator,const_iterator> equal_range(const key_type& __x) const {
00207 return _M_t.equal_range(__x);
00208 }
00209
00210 #ifdef __STL_TEMPLATE_FRIENDS
00211 template <class _K1, class _T1, class _C1, class _A1>
00212 friend bool operator== (const multimap<_K1, _T1, _C1, _A1>&,
00213 const multimap<_K1, _T1, _C1, _A1>&);
00214 template <class _K1, class _T1, class _C1, class _A1>
00215 friend bool operator< (const multimap<_K1, _T1, _C1, _A1>&,
00216 const multimap<_K1, _T1, _C1, _A1>&);
00217 #else
00218 friend bool __STD_QUALIFIER
00219 operator== __STL_NULL_TMPL_ARGS (const multimap&, const multimap&);
00220 friend bool __STD_QUALIFIER
00221 operator< __STL_NULL_TMPL_ARGS (const multimap&, const multimap&);
00222 #endif
00223 };
00224
00225 template <class _Key, class _Tp, class _Compare, class _Alloc>
00226 inline bool operator==(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
00227 const multimap<_Key,_Tp,_Compare,_Alloc>& __y) {
00228 return __x._M_t == __y._M_t;
00229 }
00230
00231 template <class _Key, class _Tp, class _Compare, class _Alloc>
00232 inline bool operator<(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
00233 const multimap<_Key,_Tp,_Compare,_Alloc>& __y) {
00234 return __x._M_t < __y._M_t;
00235 }
00236
00237 #ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER
00238
00239 template <class _Key, class _Tp, class _Compare, class _Alloc>
00240 inline bool operator!=(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
00241 const multimap<_Key,_Tp,_Compare,_Alloc>& __y) {
00242 return !(__x == __y);
00243 }
00244
00245 template <class _Key, class _Tp, class _Compare, class _Alloc>
00246 inline bool operator>(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
00247 const multimap<_Key,_Tp,_Compare,_Alloc>& __y) {
00248 return __y < __x;
00249 }
00250
00251 template <class _Key, class _Tp, class _Compare, class _Alloc>
00252 inline bool operator<=(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
00253 const multimap<_Key,_Tp,_Compare,_Alloc>& __y) {
00254 return !(__y < __x);
00255 }
00256
00257 template <class _Key, class _Tp, class _Compare, class _Alloc>
00258 inline bool operator>=(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
00259 const multimap<_Key,_Tp,_Compare,_Alloc>& __y) {
00260 return !(__x < __y);
00261 }
00262
00263 template <class _Key, class _Tp, class _Compare, class _Alloc>
00264 inline void swap(multimap<_Key,_Tp,_Compare,_Alloc>& __x,
00265 multimap<_Key,_Tp,_Compare,_Alloc>& __y) {
00266 __x.swap(__y);
00267 }
00268
00269 #endif
00270
00271 #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
00272 #pragma reset woff 1174
00273 #pragma reset woff 1375
00274 #endif
00275
00276 __STL_END_NAMESPACE
00277
00278 #endif
00279
00280
00281
00282