_tree.h

00001 /*
00002  *
00003  * Copyright (c) 1994
00004  * Hewlett-Packard Company
00005  *
00006  * Copyright (c) 1996,1997
00007  * Silicon Graphics Computer Systems, Inc.
00008  *
00009  * Copyright (c) 1997
00010  * Moscow Center for SPARC Technology
00011  *
00012  * Copyright (c) 1999 
00013  * Boris Fomitchev
00014  *
00015  * This material is provided "as is", with absolutely no warranty expressed
00016  * or implied. Any use is at your own risk.
00017  *
00018  * Permission to use or copy this software for any purpose is hereby granted 
00019  * without fee, provided the above notices are retained on all copies.
00020  * Permission to modify the code and to distribute modified code is granted,
00021  * provided the above notices are retained, and a notice that the code was
00022  * modified is included with the above copyright notice.
00023  *
00024  */
00025 
00026 /* NOTE: This is an internal header file, included by other STL headers.
00027  *   You should not attempt to use it directly.
00028  */
00029 
00030 #ifndef _STLP_INTERNAL_TREE_H
00031 #define _STLP_INTERNAL_TREE_H
00032 
00033 /*
00034 
00035 Red-black tree class, designed for use in implementing STL
00036 associative containers (set, multiset, map, and multimap). The
00037 insertion and deletion algorithms are based on those in Cormen,
00038 Leiserson, and Rivest, Introduction to Algorithms (MIT Press, 1990),
00039 except that
00040 
00041 (1) the header cell is maintained with links not only to the root
00042 but also to the leftmost node of the tree, to enable constant time
00043 begin(), and to the rightmost node of the tree, to enable linear time
00044 performance when used with the generic set algorithms (set_union,
00045 etc.);
00046 
00047 (2) when a node being deleted has two children its successor node is
00048 relinked into its place, rather than copied, so that the only
00049 iterators invalidated are those referring to the deleted node.
00050 
00051 */
00052 
00053 # ifndef _STLP_INTERNAL_ALGOBASE_H
00054 #  include <stl/_algobase.h> 
00055 # endif
00056 
00057 # ifndef _STLP_INTERNAL_ALLOC_H
00058 #  include <stl/_alloc.h> 
00059 # endif
00060 
00061 # ifndef _STLP_INTERNAL_ITERATOR_H
00062 #  include <stl/_iterator.h> 
00063 # endif
00064 
00065 # ifndef _STLP_INTERNAL_CONSTRUCT_H
00066 #  include <stl/_construct.h> 
00067 # endif
00068 
00069 # ifndef _STLP_INTERNAL_FUNCTION_H
00070 #  include <stl/_function_base.h> 
00071 # endif
00072 
00073 #if defined ( _STLP_DEBUG)
00074 #  define _Rb_tree __WORKAROUND_DBG_RENAME(Rb_tree)
00075 #endif
00076 
00077 _STLP_BEGIN_NAMESPACE
00078 
00079 typedef bool _Rb_tree_Color_type;
00080 //const _Rb_tree_Color_type _S_rb_tree_red = false;
00081 //const _Rb_tree_Color_type _S_rb_tree_black = true;
00082 
00083 #define _S_rb_tree_red false
00084 #define _S_rb_tree_black true
00085 
00086 struct _Rb_tree_node_base
00087 {
00088   typedef _Rb_tree_Color_type _Color_type;
00089   typedef _Rb_tree_node_base* _Base_ptr;
00090 
00091   _Color_type _M_color; 
00092   _Base_ptr _M_parent;
00093   _Base_ptr _M_left;
00094   _Base_ptr _M_right;
00095 
00096   static _Base_ptr _STLP_CALL _S_minimum(_Base_ptr __x)
00097   {
00098     while (__x->_M_left != 0) __x = __x->_M_left;
00099     return __x;
00100   }
00101 
00102   static _Base_ptr _STLP_CALL _S_maximum(_Base_ptr __x)
00103   {
00104     while (__x->_M_right != 0) __x = __x->_M_right;
00105     return __x;
00106   }
00107 };
00108 
00109 template <class _Value> struct _Rb_tree_node : public _Rb_tree_node_base
00110 {
00111   _Value _M_value_field;
00112   __TRIVIAL_STUFF(_Rb_tree_node)
00113 };
00114 
00115 struct _Rb_tree_base_iterator;
00116 
00117 template <class _Dummy> class _Rb_global {
00118 public:
00119   typedef _Rb_tree_node_base* _Base_ptr;
00120   // those used to be global functions 
00121   static void _STLP_CALL _Rebalance(_Rb_tree_node_base* __x, _Rb_tree_node_base*& __root);
00122   static _Rb_tree_node_base* _STLP_CALL _Rebalance_for_erase(_Rb_tree_node_base* __z,
00123                                                              _Rb_tree_node_base*& __root,
00124                                                              _Rb_tree_node_base*& __leftmost,
00125                                                              _Rb_tree_node_base*& __rightmost);
00126   // those are from _Rb_tree_base_iterator - moved here to reduce code bloat
00127   // moved here to reduce code bloat without templatizing _Rb_tree_base_iterator
00128   static _Rb_tree_node_base*  _STLP_CALL _M_increment(_Rb_tree_node_base*);
00129   static _Rb_tree_node_base*  _STLP_CALL _M_decrement(_Rb_tree_node_base*);
00130   static void _STLP_CALL _Rotate_left(_Rb_tree_node_base* __x, _Rb_tree_node_base*& __root);
00131   static void _STLP_CALL _Rotate_right(_Rb_tree_node_base* __x, _Rb_tree_node_base*& __root); 
00132 };
00133 
00134 # if defined (_STLP_USE_TEMPLATE_EXPORT) 
00135 _STLP_EXPORT_TEMPLATE_CLASS _Rb_global<bool>;
00136 # endif
00137 
00138 typedef _Rb_global<bool> _Rb_global_inst;
00139 
00140 struct _Rb_tree_base_iterator
00141 {
00142   typedef _Rb_tree_node_base*        _Base_ptr;
00143   typedef bidirectional_iterator_tag iterator_category;
00144   typedef ptrdiff_t                  difference_type;
00145   _Base_ptr _M_node;
00146   bool operator==(const _Rb_tree_base_iterator& __y) const {
00147     return _M_node == __y._M_node;
00148   }
00149   bool operator!=(const _Rb_tree_base_iterator& __y) const {
00150     return _M_node != __y._M_node;
00151   }
00152 };
00153 
00154 
00155 template <class _Value, class _Traits> struct _Rb_tree_iterator : public _Rb_tree_base_iterator
00156 {
00157   typedef _Value value_type;
00158   typedef typename _Traits::reference  reference;
00159   typedef typename _Traits::pointer    pointer;
00160   typedef _Rb_tree_iterator<_Value, _Traits> _Self;
00161   typedef _Rb_tree_node<_Value>* _Link_type;
00162 
00163   _Rb_tree_iterator() { _M_node = 0; }
00164   _Rb_tree_iterator(_Link_type __x) { _M_node = __x; }
00165   _Rb_tree_iterator(const _Rb_tree_iterator<_Value, 
00166                     _Nonconst_traits<_Value> >& __it) { _M_node = __it._M_node; }
00167 
00168   reference operator*() const { 
00169     return _Link_type(_M_node)->_M_value_field; 
00170   }
00171   
00172   _STLP_DEFINE_ARROW_OPERATOR
00173 
00174   _Self& operator++() { _M_node = _Rb_global_inst::_M_increment(_M_node); return *this; }
00175   _Self operator++(int) {
00176     _Self __tmp = *this;
00177     _M_node = _Rb_global_inst::_M_increment(_M_node);
00178     return __tmp;
00179   }
00180     
00181   _Self& operator--() { _M_node = _Rb_global_inst::_M_decrement(_M_node); return *this; }
00182   _Self operator--(int) {
00183     _Self __tmp = *this;
00184     _M_node = _Rb_global_inst::_M_decrement(_M_node);
00185     return __tmp;
00186   }
00187 };
00188 
00189 # ifdef _STLP_USE_OLD_HP_ITERATOR_QUERIES
00190 template <class _Value, class _Traits> inline _Value* value_type(const _Rb_tree_iterator<_Value, _Traits>&) { return (_Value*)0; }
00191 inline bidirectional_iterator_tag iterator_category(const _Rb_tree_base_iterator&) { return bidirectional_iterator_tag(); }
00192 inline ptrdiff_t* distance_type(const _Rb_tree_base_iterator&) { return (ptrdiff_t*) 0; }
00193 #endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
00194 
00195 // Base class to help EH
00196 
00197 template <class _Tp, class _Alloc> struct _Rb_tree_base
00198 {
00199   typedef _Rb_tree_node<_Tp> _Node;
00200   _STLP_FORCE_ALLOCATORS(_Tp, _Alloc)
00201   typedef typename _Alloc_traits<_Tp, _Alloc>::allocator_type allocator_type;
00202 
00203   _Rb_tree_base(const allocator_type& __a) : 
00204     _M_header(_STLP_CONVERT_ALLOCATOR(__a, _Node), (_Node*)0) { 
00205       _M_header._M_data = _M_header.allocate(1); 
00206   }
00207   ~_Rb_tree_base() { 
00208     _M_header.deallocate(_M_header._M_data,1); 
00209   }
00210   allocator_type get_allocator() const { 
00211     return _STLP_CONVERT_ALLOCATOR(_M_header, _Tp); 
00212   }
00213 protected:
00214   typedef typename _Alloc_traits<_Node, _Alloc>::allocator_type _M_node_allocator_type;
00215   _STLP_alloc_proxy<_Node*, _Node, _M_node_allocator_type> _M_header;
00216 };
00217 
00218 
00219 template <class _Key, class _Value, class _KeyOfValue, class _Compare,
00220           _STLP_DEFAULT_ALLOCATOR_SELECT(_Value) > class _Rb_tree : public _Rb_tree_base<_Value, _Alloc> {
00221   typedef _Rb_tree_base<_Value, _Alloc> _Base;
00222 protected:
00223   typedef _Rb_tree_node_base* _Base_ptr;
00224   typedef _Rb_tree_node<_Value> _Node;
00225   typedef _Rb_tree_Color_type _Color_type;
00226 public:
00227   typedef _Key key_type;
00228   typedef _Value value_type;
00229   typedef value_type* pointer;
00230   typedef const value_type* const_pointer;
00231   typedef value_type& reference;
00232   typedef const value_type& const_reference;
00233   typedef _Rb_tree_node<_Value>* _Link_type;
00234   typedef size_t size_type;
00235   typedef ptrdiff_t difference_type;
00236   typedef bidirectional_iterator_tag _Iterator_category;
00237   typedef typename _Base::allocator_type allocator_type;
00238   
00239 protected:
00240 
00241   _Link_type _M_create_node(const value_type& __x)
00242   {
00243     _Link_type __tmp = this->_M_header.allocate(1);
00244     _STLP_TRY {
00245       _Construct(&__tmp->_M_value_field, __x);
00246     }
00247     _STLP_UNWIND(this->_M_header.deallocate(__tmp,1));
00248     return __tmp;
00249   }
00250 
00251   _Link_type _M_clone_node(_Link_type __x)
00252   {
00253     _Link_type __tmp = _M_create_node(__x->_M_value_field);
00254     __tmp->_M_color = __x->_M_color;
00255     __tmp->_M_left = 0;
00256     __tmp->_M_right = 0;
00257     return __tmp;
00258   }
00259 
00260 protected:
00261   size_type _M_node_count; // keeps track of size of tree
00262   _Compare _M_key_compare;
00263 
00264   _Link_type& _M_root() const 
00265     { return (_Link_type&) this->_M_header._M_data->_M_parent; }
00266   _Link_type& _M_leftmost() const 
00267     { return (_Link_type&) this->_M_header._M_data->_M_left; }
00268   _Link_type& _M_rightmost() const 
00269     { return (_Link_type&) this->_M_header._M_data->_M_right; }
00270 
00271   static _Link_type& _STLP_CALL _S_left(_Link_type __x)
00272     { return (_Link_type&)(__x->_M_left); }
00273   static _Link_type& _STLP_CALL _S_right(_Link_type __x)
00274     { return (_Link_type&)(__x->_M_right); }
00275   static _Link_type& _STLP_CALL _S_parent(_Link_type __x)
00276     { return (_Link_type&)(__x->_M_parent); }
00277   static reference  _STLP_CALL _S_value(_Link_type __x)
00278     { return __x->_M_value_field; }
00279   static const _Key& _STLP_CALL _S_key(_Link_type __x)
00280     { return _KeyOfValue()(_S_value(__x)); }
00281   static _Color_type& _STLP_CALL _S_color(_Link_type __x)
00282     { return (_Color_type&)(__x->_M_color); }
00283 
00284   static _Link_type& _STLP_CALL _S_left(_Base_ptr __x)
00285     { return (_Link_type&)(__x->_M_left); }
00286   static _Link_type& _STLP_CALL _S_right(_Base_ptr __x)
00287     { return (_Link_type&)(__x->_M_right); }
00288   static _Link_type& _STLP_CALL _S_parent(_Base_ptr __x)
00289     { return (_Link_type&)(__x->_M_parent); }
00290   static reference  _STLP_CALL _S_value(_Base_ptr __x)
00291     { return ((_Link_type)__x)->_M_value_field; }
00292   static const _Key& _STLP_CALL _S_key(_Base_ptr __x)
00293     { return _KeyOfValue()(_S_value(_Link_type(__x)));} 
00294   static _Color_type& _STLP_CALL _S_color(_Base_ptr __x)
00295     { return (_Color_type&)(_Link_type(__x)->_M_color); }
00296 
00297   static _Link_type  _STLP_CALL _S_minimum(_Link_type __x) 
00298     { return (_Link_type)  _Rb_tree_node_base::_S_minimum(__x); }
00299 
00300   static _Link_type  _STLP_CALL _S_maximum(_Link_type __x)
00301     { return (_Link_type) _Rb_tree_node_base::_S_maximum(__x); }
00302 
00303 public:
00304   typedef _Rb_tree_iterator<value_type, _Nonconst_traits<value_type> > iterator;
00305   typedef _Rb_tree_iterator<value_type, _Const_traits<value_type> > const_iterator;
00306   _STLP_DECLARE_BIDIRECTIONAL_REVERSE_ITERATORS;
00307 
00308 private:
00309   iterator _M_insert(_Base_ptr __x, _Base_ptr __y, const value_type& __v, _Base_ptr __w = 0);
00310   _Link_type _M_copy(_Link_type __x, _Link_type __p);
00311   void _M_erase(_Link_type __x);
00312 
00313 public:
00314                                 // allocation/deallocation
00315   _Rb_tree()
00316     : _Rb_tree_base<_Value, _Alloc>(allocator_type()), _M_node_count(0), _M_key_compare(_Compare())
00317     { _M_empty_initialize(); }
00318 
00319   _Rb_tree(const _Compare& __comp)
00320     : _Rb_tree_base<_Value, _Alloc>(allocator_type()), _M_node_count(0), _M_key_compare(__comp) 
00321     { _M_empty_initialize(); }
00322 
00323   _Rb_tree(const _Compare& __comp, const allocator_type& __a)
00324     : _Rb_tree_base<_Value, _Alloc>(__a), _M_node_count(0), _M_key_compare(__comp) 
00325     { _M_empty_initialize(); }
00326 
00327   _Rb_tree(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x) 
00328     : _Rb_tree_base<_Value, _Alloc>(__x.get_allocator()),
00329       _M_node_count(0), _M_key_compare(__x._M_key_compare)
00330   { 
00331     if (__x._M_root() == 0)
00332       _M_empty_initialize();
00333     else {
00334       _S_color(this->_M_header._M_data) = _S_rb_tree_red;
00335       _M_root() = _M_copy(__x._M_root(), this->_M_header._M_data);
00336       _M_leftmost() = _S_minimum(_M_root());
00337       _M_rightmost() = _S_maximum(_M_root());
00338     }
00339     _M_node_count = __x._M_node_count;
00340   }
00341   ~_Rb_tree() { clear(); }
00342   _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& operator=(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x);
00343 
00344 private:
00345   void _M_empty_initialize() {
00346     _S_color(this->_M_header._M_data) = _S_rb_tree_red; // used to distinguish header from 
00347                                           // __root, in iterator.operator++
00348     _M_root() = 0;
00349     _M_leftmost() = this->_M_header._M_data;
00350     _M_rightmost() = this->_M_header._M_data;
00351   }
00352 
00353 public:    
00354                                 // accessors:
00355   _Compare key_comp() const { return _M_key_compare; }
00356 
00357   iterator begin() { return iterator(_M_leftmost()); }
00358   const_iterator begin() const { return const_iterator(_M_leftmost()); }
00359   iterator end() { return iterator(this->_M_header._M_data); }
00360   const_iterator end() const { return const_iterator(this->_M_header._M_data); }
00361 
00362   reverse_iterator rbegin() { return reverse_iterator(end()); }
00363   const_reverse_iterator rbegin() const { 
00364     return const_reverse_iterator(end()); 
00365   }
00366   reverse_iterator rend() { return reverse_iterator(begin()); }
00367   const_reverse_iterator rend() const { 
00368     return const_reverse_iterator(begin());
00369   } 
00370   bool empty() const { return _M_node_count == 0; }
00371   size_type size() const { return _M_node_count; }
00372   size_type max_size() const { return size_type(-1); }
00373 
00374   void swap(_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __t) {
00375     _STLP_STD::swap(this->_M_header._M_data, __t._M_header._M_data);
00376     _STLP_STD::swap(_M_node_count, __t._M_node_count);
00377     _STLP_STD::swap(_M_key_compare, __t._M_key_compare);
00378   }
00379     
00380 public:
00381                                 // insert/erase
00382   pair<iterator,bool> insert_unique(const value_type& __x);
00383   iterator insert_equal(const value_type& __x);
00384 
00385   iterator insert_unique(iterator __position, const value_type& __x);
00386   iterator insert_equal(iterator __position, const value_type& __x);
00387 
00388 #ifdef _STLP_MEMBER_TEMPLATES  
00389   template<class _II> void insert_equal(_II __first, _II __last) {
00390     for ( ; __first != __last; ++__first)
00391       insert_equal(*__first);
00392   }
00393   template<class _II> void insert_unique(_II __first, _II __last) {
00394     for ( ; __first != __last; ++__first)
00395       insert_unique(*__first);
00396   }
00397 #else /* _STLP_MEMBER_TEMPLATES */
00398   void insert_unique(const_iterator __first, const_iterator __last) {
00399     for ( ; __first != __last; ++__first)
00400       insert_unique(*__first);
00401   }
00402   void insert_unique(const value_type* __first, const value_type* __last) {
00403     for ( ; __first != __last; ++__first)
00404       insert_unique(*__first);
00405   }
00406   void insert_equal(const_iterator __first, const_iterator __last) {
00407     for ( ; __first != __last; ++__first)
00408       insert_equal(*__first);
00409   }
00410   void insert_equal(const value_type* __first, const value_type* __last) {
00411     for ( ; __first != __last; ++__first)
00412       insert_equal(*__first);
00413   }
00414 #endif /* _STLP_MEMBER_TEMPLATES */
00415 
00416   void erase(iterator __position) {
00417     _Link_type __y = 
00418       (_Link_type) _Rb_global_inst::_Rebalance_for_erase(__position._M_node,
00419                                                          this->_M_header._M_data->_M_parent,
00420                                                          this->_M_header._M_data->_M_left,
00421                                                          this->_M_header._M_data->_M_right);
00422     _Destroy(&__y->_M_value_field);
00423     this->_M_header.deallocate(__y,1);
00424     --_M_node_count;
00425   }
00426   
00427   size_type erase(const key_type& __x) {
00428     pair<iterator,iterator> __p = equal_range(__x);
00429     size_type __n = distance(__p.first, __p.second);
00430     erase(__p.first, __p.second);
00431     return __n;
00432   }
00433   
00434   void erase(iterator __first, iterator __last) {
00435     if (__first == begin() && __last == end())
00436       clear();
00437     else
00438       while (__first != __last) erase(__first++);
00439   }
00440 
00441   void erase(const key_type* __first, const key_type* __last) {
00442     while (__first != __last) erase(*__first++);
00443   }
00444 
00445   void clear() {
00446     if (_M_node_count != 0) {
00447       _M_erase(_M_root());
00448       _M_leftmost() = this->_M_header._M_data;
00449       _M_root() = 0;
00450       _M_rightmost() = this->_M_header._M_data;
00451       _M_node_count = 0;
00452     }
00453   }      
00454 
00455 public:
00456                                 // set operations:
00457 # if defined(_STLP_MEMBER_TEMPLATES) && ! defined ( _STLP_NO_EXTENSIONS ) && !defined(__MRC__) && !defined(__SC__)
00458   template <class _KT> iterator find(const _KT& __x) { return iterator(_M_find(__x)); }
00459   template <class _KT> const_iterator find(const _KT& __x) const { return const_iterator(_M_find(__x)); }
00460 private:
00461   template <class _KT> _Rb_tree_node<_Value>* _M_find(const _KT& __k) const
00462 # else
00463   iterator find(const key_type& __x) { return iterator(_M_find(__x)); }
00464   const_iterator find(const key_type& __x) const { return const_iterator(_M_find(__x)); }
00465 private:
00466   _Rb_tree_node<_Value>* _M_find(const key_type& __k) const
00467 # endif
00468   {
00469     _Link_type __y = this->_M_header._M_data;      // Last node which is not less than __k. 
00470     _Link_type __x = _M_root();      // Current node. 
00471     
00472     while (__x != 0) 
00473       if (!_M_key_compare(_S_key(__x), __k))
00474         __y = __x, __x = _S_left(__x);
00475       else
00476         __x = _S_right(__x);
00477     if (__y == this->_M_header._M_data || _M_key_compare(__k, _S_key(__y)))
00478       __y = this->_M_header._M_data;
00479     return __y;
00480   }
00481   
00482   _Link_type _M_lower_bound(const key_type& __k) const {
00483     _Link_type __y = this->_M_header._M_data; /* Last node which is not less than __k. */
00484     _Link_type __x = _M_root(); /* Current node. */
00485     
00486     while (__x != 0) 
00487       if (!_M_key_compare(_S_key(__x), __k))
00488         __y = __x, __x = _S_left(__x);
00489       else
00490         __x = _S_right(__x);
00491     
00492     return __y;
00493   }
00494 
00495   _Link_type _M_upper_bound(const key_type& __k) const {
00496     _Link_type __y = this->_M_header._M_data; /* Last node which is greater than __k. */
00497     _Link_type __x = _M_root(); /* Current node. */
00498     
00499     while (__x != 0) 
00500       if (_M_key_compare(__k, _S_key(__x)))
00501         __y = __x, __x = _S_left(__x);
00502       else
00503         __x = _S_right(__x);
00504     
00505     return __y;
00506   }
00507   
00508 public:  
00509   size_type count(const key_type& __x) const;
00510   iterator lower_bound(const key_type& __x) { return iterator(_M_lower_bound(__x)); }
00511   const_iterator lower_bound(const key_type& __x) const { return const_iterator(_M_lower_bound(__x)); }
00512   iterator upper_bound(const key_type& __x) { return iterator(_M_upper_bound(__x)); }
00513   const_iterator upper_bound(const key_type& __x) const { return const_iterator(_M_upper_bound(__x)); }
00514   pair<iterator,iterator> equal_range(const key_type& __x) {
00515     return pair<iterator, iterator>(lower_bound(__x), upper_bound(__x));
00516   }
00517   pair<const_iterator, const_iterator> equal_range(const key_type& __x) const {
00518     return pair<const_iterator,const_iterator>(lower_bound(__x),
00519                                                upper_bound(__x));
00520   }
00521 
00522 public:
00523                                 // Debugging.
00524   bool __rb_verify() const;
00525 };
00526 
00527 template <class _Key, class _Value, class _KeyOfValue, 
00528           class _Compare, class _Alloc> inline bool _STLP_CALL 
00529 operator==(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x, 
00530            const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __y)
00531 {
00532   return __x.size() == __y.size() && equal(__x.begin(), __x.end(), __y.begin());
00533 }
00534 
00535 template <class _Key, class _Value, class _KeyOfValue, 
00536           class _Compare, class _Alloc> inline bool _STLP_CALL 
00537 operator<(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x, 
00538           const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __y)
00539 {
00540   return lexicographical_compare(__x.begin(), __x.end(), 
00541                                  __y.begin(), __y.end());
00542 }
00543 
00544 #ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE
00545 
00546 template <class _Key, class _Value, class _KeyOfValue, 
00547           class _Compare, class _Alloc> inline bool _STLP_CALL 
00548 operator!=(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x, 
00549            const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __y) {
00550   return !(__x == __y);
00551 }
00552 
00553 template <class _Key, class _Value, class _KeyOfValue, 
00554           class _Compare, class _Alloc> inline bool _STLP_CALL 
00555 operator>(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x, 
00556           const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __y) {
00557   return __y < __x;
00558 }
00559 
00560 template <class _Key, class _Value, class _KeyOfValue, 
00561           class _Compare, class _Alloc> inline bool _STLP_CALL 
00562 operator<=(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x, 
00563            const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __y) {
00564   return !(__y < __x);
00565 }
00566 
00567 template <class _Key, class _Value, class _KeyOfValue, 
00568           class _Compare, class _Alloc> inline bool _STLP_CALL 
00569 operator>=(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x, 
00570            const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __y) {
00571   return !(__x < __y);
00572 }
00573 
00574 #endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */
00575 
00576 #ifdef _STLP_FUNCTION_TMPL_PARTIAL_ORDER
00577 
00578 template <class _Key, class _Value, class _KeyOfValue, 
00579           class _Compare, class _Alloc> inline void _STLP_CALL 
00580 swap(_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x, 
00581      _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __y)
00582 {
00583   __x.swap(__y);
00584 }
00585 
00586 #endif /* _STLP_FUNCTION_TMPL_PARTIAL_ORDER */
00587          
00588 _STLP_END_NAMESPACE
00589 
00590 # if !defined (_STLP_LINK_TIME_INSTANTIATION)
00591 #  include <stl/_tree.c> 
00592 # endif
00593 
00594 # undef _Rb_tree
00595 
00596 #if defined (_STLP_DEBUG)
00597 # include <stl/debug/_tree.h> 
00598 #endif
00599 
00600 _STLP_BEGIN_NAMESPACE
00601 // Class rb_tree is not part of the C++ standard.  It is provided for
00602 // compatibility with the HP STL.
00603 
00604 template <class _Key, class _Value, class _KeyOfValue, class _Compare,
00605           _STLP_DEFAULT_ALLOCATOR_SELECT(_Value) > struct rb_tree : public _Rb_tree<_Key, _Value, _KeyOfValue, _Compare, _Alloc> {
00606   typedef _Rb_tree<_Key, _Value, _KeyOfValue, _Compare, _Alloc> _Base;
00607   typedef typename _Base::allocator_type allocator_type;
00608 
00609   rb_tree()
00610      : _Rb_tree<_Key, _Value, _KeyOfValue, _Compare, _Alloc>(_Compare(), allocator_type()) {}
00611   rb_tree(const _Compare& __comp,
00612           const allocator_type& __a = allocator_type())
00613     : _Rb_tree<_Key, _Value, _KeyOfValue, _Compare, _Alloc>(__comp, __a) {} 
00614   ~rb_tree() {}
00615 };
00616 _STLP_END_NAMESPACE
00617 
00618 #endif /* _STLP_INTERNAL_TREE_H */
00619 
00620 // Local Variables:
00621 // mode:C++
00622 // End:

Generated on Mon Jun 5 10:20:47 2006 for Intelligence.kdevelop by  doxygen 1.4.6