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