Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
4 * Hewlett-Packard Company
6 * Copyright (c) 1996,1997
7 * Silicon Graphics Computer Systems, Inc.
10 * Moscow Center for SPARC Technology
15 * This material is provided "as is", with absolutely no warranty expressed
16 * or implied. Any use is at your own risk.
18 * Permission to use or copy this software for any purpose is hereby granted
19 * without fee, provided the above notices are retained on all copies.
20 * Permission to modify the code and to distribute modified code is granted,
21 * provided the above notices are retained, and a notice that the code was
22 * modified is included with the above copyright notice.
26 /* NOTE: This is an internal header file, included by other STL headers.
27 * You should not attempt to use it directly.
30 #ifndef _STLP_INTERNAL_DBG_TREE_H
31 #define _STLP_INTERNAL_DBG_TREE_H
33 #include <stl/debug/_iterator.h>
34 #include <stl/_function.h>
35 #include <stl/_alloc.h>
38 # define _DBG_Rb_tree _Rb_tree
40 # define _STLP_DBG_TREE_SUPER __WORKAROUND_DBG_RENAME(Rb_tree) <_Key, _Value, _KeyOfValue, _Compare, _Alloc>
44 # ifdef _STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS
45 template <class _Key, class _Value, class _KeyOfValue, class _Compare, class _Alloc >
47 value_type(const _DBG_iter_base< _STLP_DBG_TREE_SUPER >&) {
50 template <class _Key, class _Value, class _KeyOfValue, class _Compare, class _Alloc >
51 inline bidirectional_iterator_tag
52 iterator_category(const _DBG_iter_base< _STLP_DBG_TREE_SUPER >&) {
53 return bidirectional_iterator_tag();
57 template <class _Key, class _Value, class _KeyOfValue, class _Compare,
58 _STLP_DBG_ALLOCATOR_SELECT(_Value) >
59 class _DBG_Rb_tree : public _STLP_DBG_TREE_SUPER {
60 typedef _STLP_DBG_TREE_SUPER _Base;
61 typedef _DBG_Rb_tree<_Key, _Value, _KeyOfValue, _Compare, _Alloc> _Self;
63 friend class __owned_link;
64 mutable __owned_list _M_iter_list;
67 __IMPORT_CONTAINER_TYPEDEFS(_Base)
68 typedef typename _Base::key_type key_type;
70 typedef _DBG_iter<_Base, _Nonconst_traits<value_type> > iterator;
71 typedef _DBG_iter<_Base, _Const_traits<value_type> > const_iterator;
73 _STLP_DECLARE_BIDIRECTIONAL_REVERSE_ITERATORS;
77 //typedef typename _Base::key_param_type key_param_type;
78 //typedef typename _Base::val_param_type val_param_type;
80 void _Invalidate_all() {_M_iter_list._Invalidate_all();}
82 void _Invalidate_iterator(const iterator& __it) {
83 __invalidate_iterator(&_M_iter_list,__it);
85 void _Invalidate_iterators(const iterator& __first, const iterator& __last) {
86 iterator __cur = __first;
87 while (__cur != __last) __invalidate_iterator(&_M_iter_list, __cur++);
90 const _Base* _Get_base() const { return (const _Base*)this; }
91 _Base* _Get_base() { return (_Base*)this; }
94 _DBG_Rb_tree() : _STLP_DBG_TREE_SUPER(),
95 _M_iter_list(_Get_base()) {}
96 _DBG_Rb_tree(const _Compare& __comp) :
97 _STLP_DBG_TREE_SUPER(__comp), _M_iter_list(_Get_base()) {}
98 _DBG_Rb_tree(const _Compare& __comp, const allocator_type& __a):
99 _STLP_DBG_TREE_SUPER(__comp, __a), _M_iter_list(_Get_base()) {}
100 _DBG_Rb_tree(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x):
101 _STLP_DBG_TREE_SUPER(__x), _M_iter_list(_Get_base()) {}
102 ~_DBG_Rb_tree() { _Invalidate_all(); }
104 _Self& operator=(const _Self& __x) {
106 (_Base&)*this = (const _Base&)__x;
110 iterator begin() { return iterator(&_M_iter_list,_Base::begin()); }
111 const_iterator begin() const { return const_iterator(&_M_iter_list, _Base::begin()); }
112 iterator end() { return iterator(&_M_iter_list, _Base::end()); }
113 const_iterator end() const { return const_iterator(&_M_iter_list,_Base::end()); }
116 reverse_iterator rbegin() { return reverse_iterator(end()); }
117 const_reverse_iterator rbegin() const {
118 return const_reverse_iterator(end());
120 reverse_iterator rend() { return reverse_iterator(begin()); }
121 const_reverse_iterator rend() const {
122 return const_reverse_iterator(begin());
124 void swap(_Self& __t) {
126 _M_iter_list._Swap_owners(__t._M_iter_list);
131 iterator find(const key_type& __x) {
132 return iterator(&_M_iter_list, _Base::find(__x));
134 const_iterator find(const key_type& __x) const {
135 return const_iterator(&_M_iter_list, _Base::find(__x));
138 iterator lower_bound(const key_type& __x) {
139 return iterator(&_M_iter_list, _Base::lower_bound(__x));
141 const_iterator lower_bound(const key_type& __x) const {
142 return const_iterator(&_M_iter_list, _Base::lower_bound(__x));
145 iterator upper_bound(const key_type& __x) {
146 return iterator(&_M_iter_list, _Base::upper_bound(__x));
148 const_iterator upper_bound(const key_type& __x) const {
149 return const_iterator(&_M_iter_list, _Base::upper_bound(__x));
152 pair<iterator,iterator> equal_range(const key_type& __x) {
153 return pair<iterator, iterator>(iterator(&_M_iter_list, _Base::lower_bound(__x)),
154 iterator(&_M_iter_list, _Base::upper_bound(__x)));
156 pair<const_iterator, const_iterator> equal_range(const key_type& __x) const {
157 return pair<const_iterator,const_iterator>(const_iterator(&_M_iter_list, _Base::lower_bound(__x)),
158 const_iterator(&_M_iter_list, _Base::upper_bound(__x)));
161 pair<iterator,bool> insert_unique(const value_type& __x) {
162 _STLP_STD::pair<_STLP_HEADER_TYPENAME _Base::iterator, bool> __res = _Base::insert_unique(__x);
163 return pair<iterator,bool>( iterator(&_M_iter_list, __res.first), __res.second ) ;
165 iterator insert_equal(const value_type& __x) {
166 return iterator(&_M_iter_list, _Base::insert_equal(__x));
169 iterator insert_unique(iterator __position, const value_type& __x) {
170 _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__position))
171 return iterator(&_M_iter_list, _Base::insert_unique(__position._M_iterator, __x));
173 iterator insert_equal(iterator __position, const value_type& __x) {
174 _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__position))
175 return iterator(&_M_iter_list, _Base::insert_equal(__position._M_iterator, __x));
178 #ifdef _STLP_MEMBER_TEMPLATES
180 void insert_equal(_II __first, _II __last) {
181 _Base::insert_equal(__first, __last);
184 void insert_unique(_II __first, _II __last) {
185 _Base::insert_unique(__first, __last);
187 #else /* _STLP_MEMBER_TEMPLATES */
188 void insert_unique(const_iterator __first, const_iterator __last) {
189 _Base::insert_unique(__first._M_iterator, __last._M_iterator);
191 void insert_unique(const value_type* __first, const value_type* __last) {
192 _Base::insert_unique(__first, __last);
194 void insert_equal(const_iterator __first, const_iterator __last) {
195 _Base::insert_equal(__first._M_iterator, __last._M_iterator);
197 void insert_equal(const value_type* __first, const value_type* __last) {
198 _Base::insert_equal(__first, __last);
200 #endif /* _STLP_MEMBER_TEMPLATES */
202 void erase(iterator __position) {
203 _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__position))
204 _STLP_DEBUG_CHECK(_Dereferenceable(__position))
205 _Invalidate_iterator(__position);
206 _Base::erase(__position._M_iterator);
208 size_type erase(const key_type& __x) {
209 pair<iterator,iterator> __p = equal_range(__x);
210 size_type __n = distance(__p.first, __p.second);
211 _Invalidate_iterators(__p.first, __p.second);
212 _Base::erase(__p.first._M_iterator, __p.second._M_iterator);
216 void erase(iterator __first, iterator __last) {
217 _STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __first)&&
218 __check_if_owner(&_M_iter_list, __last))
219 _Invalidate_iterators(__first, __last);
220 _Base::erase(__first._M_iterator, __last._M_iterator);
222 void erase(const key_type* __first, const key_type* __last) {
223 while (__first != __last) erase(*__first++);
232 #define _STLP_TEMPLATE_HEADER template <class _Key, class _Value, class _KeyOfValue, class _Compare, class _Alloc>
233 #define _STLP_TEMPLATE_CONTAINER _DBG_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>
234 #define _STLP_TEMPLATE_CONTAINER_BASE _STLP_DBG_TREE_SUPER
235 #include <stl/debug/_relops_cont.h>
236 #undef _STLP_TEMPLATE_CONTAINER_BASE
237 #undef _STLP_TEMPLATE_CONTAINER
238 #undef _STLP_TEMPLATE_HEADER
242 # undef _STLP_DBG_TREE_SUPER
244 #endif /* _STLP_INTERNAL_DBG_TREE_H */