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