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_MULTISET_H
00061 #define __SGI_STL_INTERNAL_MULTISET_H
00062
00063 #include <bits/concept_check.h>
00064
00065 namespace std
00066 {
00067
00068
00069
00070 template <class _Key, class _Compare = less<_Key>,
00071 class _Alloc = allocator<_Key> >
00072 class multiset;
00073
00074 template <class _Key, class _Compare, class _Alloc>
00075 inline bool operator==(const multiset<_Key,_Compare,_Alloc>& __x,
00076 const multiset<_Key,_Compare,_Alloc>& __y);
00077
00078 template <class _Key, class _Compare, class _Alloc>
00079 inline bool operator<(const multiset<_Key,_Compare,_Alloc>& __x,
00080 const multiset<_Key,_Compare,_Alloc>& __y);
00081
00082 template <class _Key, class _Compare, class _Alloc>
00083 class multiset
00084 {
00085
00086 __glibcpp_class_requires(_Key, _SGIAssignableConcept);
00087 __glibcpp_class_requires4(_Compare, bool, _Key, _Key, _BinaryFunctionConcept);
00088
00089 public:
00090
00091
00092
00093 typedef _Key key_type;
00094 typedef _Key value_type;
00095 typedef _Compare key_compare;
00096 typedef _Compare value_compare;
00097 private:
00098 typedef _Rb_tree<key_type, value_type,
00099 _Identity<value_type>, key_compare, _Alloc> _Rep_type;
00100 _Rep_type _M_t;
00101 public:
00102 typedef typename _Rep_type::const_pointer pointer;
00103 typedef typename _Rep_type::const_pointer const_pointer;
00104 typedef typename _Rep_type::const_reference reference;
00105 typedef typename _Rep_type::const_reference const_reference;
00106 typedef typename _Rep_type::const_iterator iterator;
00107 typedef typename _Rep_type::const_iterator const_iterator;
00108 typedef typename _Rep_type::const_reverse_iterator reverse_iterator;
00109 typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
00110 typedef typename _Rep_type::size_type size_type;
00111 typedef typename _Rep_type::difference_type difference_type;
00112 typedef typename _Rep_type::allocator_type allocator_type;
00113
00114
00115
00116 multiset() : _M_t(_Compare(), allocator_type()) {}
00117 explicit multiset(const _Compare& __comp,
00118 const allocator_type& __a = allocator_type())
00119 : _M_t(__comp, __a) {}
00120
00121 template <class _InputIterator>
00122 multiset(_InputIterator __first, _InputIterator __last)
00123 : _M_t(_Compare(), allocator_type())
00124 { _M_t.insert_equal(__first, __last); }
00125
00126 template <class _InputIterator>
00127 multiset(_InputIterator __first, _InputIterator __last,
00128 const _Compare& __comp,
00129 const allocator_type& __a = allocator_type())
00130 : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); }
00131
00132 multiset(const multiset<_Key,_Compare,_Alloc>& __x) : _M_t(__x._M_t) {}
00133
00134 multiset<_Key,_Compare,_Alloc>&
00135 operator=(const multiset<_Key,_Compare,_Alloc>& __x) {
00136 _M_t = __x._M_t;
00137 return *this;
00138 }
00139
00140
00141
00142 key_compare key_comp() const { return _M_t.key_comp(); }
00143 value_compare value_comp() const { return _M_t.key_comp(); }
00144 allocator_type get_allocator() const { return _M_t.get_allocator(); }
00145
00146 iterator begin() const { return _M_t.begin(); }
00147 iterator end() const { return _M_t.end(); }
00148 reverse_iterator rbegin() const { return _M_t.rbegin(); }
00149 reverse_iterator rend() const { return _M_t.rend(); }
00150 bool empty() const { return _M_t.empty(); }
00151 size_type size() const { return _M_t.size(); }
00152 size_type max_size() const { return _M_t.max_size(); }
00153 void swap(multiset<_Key,_Compare,_Alloc>& __x) { _M_t.swap(__x._M_t); }
00154
00155
00156 iterator insert(const value_type& __x) {
00157 return _M_t.insert_equal(__x);
00158 }
00159 iterator insert(iterator __position, const value_type& __x) {
00160 typedef typename _Rep_type::iterator _Rep_iterator;
00161 return _M_t.insert_equal((_Rep_iterator&)__position, __x);
00162 }
00163
00164 template <class _InputIterator>
00165 void insert(_InputIterator __first, _InputIterator __last) {
00166 _M_t.insert_equal(__first, __last);
00167 }
00168 void erase(iterator __position) {
00169 typedef typename _Rep_type::iterator _Rep_iterator;
00170 _M_t.erase((_Rep_iterator&)__position);
00171 }
00172 size_type erase(const key_type& __x) {
00173 return _M_t.erase(__x);
00174 }
00175 void erase(iterator __first, iterator __last) {
00176 typedef typename _Rep_type::iterator _Rep_iterator;
00177 _M_t.erase((_Rep_iterator&)__first, (_Rep_iterator&)__last);
00178 }
00179 void clear() { _M_t.clear(); }
00180
00181
00182
00183 size_type count(const key_type& __x) const { return _M_t.count(__x); }
00184
00185 #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
00186
00187 iterator find(const key_type& __x) { return _M_t.find(__x); }
00188 const_iterator find(const key_type& __x) const { return _M_t.find(__x); }
00189 iterator lower_bound(const key_type& __x) {
00190 return _M_t.lower_bound(__x);
00191 }
00192 const_iterator lower_bound(const key_type& __x) const {
00193 return _M_t.lower_bound(__x);
00194 }
00195 iterator upper_bound(const key_type& __x) {
00196 return _M_t.upper_bound(__x);
00197 }
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 #else
00208 iterator find(const key_type& __x) const { return _M_t.find(__x); }
00209 iterator lower_bound(const key_type& __x) const {
00210 return _M_t.lower_bound(__x);
00211 }
00212 iterator upper_bound(const key_type& __x) const {
00213 return _M_t.upper_bound(__x);
00214 }
00215 pair<iterator,iterator> equal_range(const key_type& __x) const {
00216 return _M_t.equal_range(__x);
00217 }
00218 #endif
00219
00220 template <class _K1, class _C1, class _A1>
00221 friend bool operator== (const multiset<_K1,_C1,_A1>&,
00222 const multiset<_K1,_C1,_A1>&);
00223 template <class _K1, class _C1, class _A1>
00224 friend bool operator< (const multiset<_K1,_C1,_A1>&,
00225 const multiset<_K1,_C1,_A1>&);
00226 };
00227
00228 template <class _Key, class _Compare, class _Alloc>
00229 inline bool operator==(const multiset<_Key,_Compare,_Alloc>& __x,
00230 const multiset<_Key,_Compare,_Alloc>& __y) {
00231 return __x._M_t == __y._M_t;
00232 }
00233
00234 template <class _Key, class _Compare, class _Alloc>
00235 inline bool operator<(const multiset<_Key,_Compare,_Alloc>& __x,
00236 const multiset<_Key,_Compare,_Alloc>& __y) {
00237 return __x._M_t < __y._M_t;
00238 }
00239
00240 template <class _Key, class _Compare, class _Alloc>
00241 inline bool operator!=(const multiset<_Key,_Compare,_Alloc>& __x,
00242 const multiset<_Key,_Compare,_Alloc>& __y) {
00243 return !(__x == __y);
00244 }
00245
00246 template <class _Key, class _Compare, class _Alloc>
00247 inline bool operator>(const multiset<_Key,_Compare,_Alloc>& __x,
00248 const multiset<_Key,_Compare,_Alloc>& __y) {
00249 return __y < __x;
00250 }
00251
00252 template <class _Key, class _Compare, class _Alloc>
00253 inline bool operator<=(const multiset<_Key,_Compare,_Alloc>& __x,
00254 const multiset<_Key,_Compare,_Alloc>& __y) {
00255 return !(__y < __x);
00256 }
00257
00258 template <class _Key, class _Compare, class _Alloc>
00259 inline bool operator>=(const multiset<_Key,_Compare,_Alloc>& __x,
00260 const multiset<_Key,_Compare,_Alloc>& __y) {
00261 return !(__x < __y);
00262 }
00263
00264 template <class _Key, class _Compare, class _Alloc>
00265 inline void swap(multiset<_Key,_Compare,_Alloc>& __x,
00266 multiset<_Key,_Compare,_Alloc>& __y) {
00267 __x.swap(__y);
00268 }
00269
00270 }
00271
00272 #endif
00273
00274
00275
00276