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