gccxml_gem 0.9.3-x86-darwin-10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. data/Rakefile +84 -0
  2. data/bin/gccxml +0 -0
  3. data/bin/gccxml_cc1plus +0 -0
  4. data/gccxml.rb +57 -0
  5. data/share/doc/gccxml-0.9/Copyright.txt +55 -0
  6. data/share/doc/gccxml-0.9/gccxml.html +168 -0
  7. data/share/doc/gccxml-0.9/gccxml.txt +293 -0
  8. data/share/gccxml-0.9/GCC/2.95/algorithm +76 -0
  9. data/share/gccxml-0.9/GCC/2.95/bitset +17 -0
  10. data/share/gccxml-0.9/GCC/2.95/cctype +24 -0
  11. data/share/gccxml-0.9/GCC/2.95/clocale +14 -0
  12. data/share/gccxml-0.9/GCC/2.95/cmath +33 -0
  13. data/share/gccxml-0.9/GCC/2.95/complex +38 -0
  14. data/share/gccxml-0.9/GCC/2.95/csetjmp +13 -0
  15. data/share/gccxml-0.9/GCC/2.95/csignal +14 -0
  16. data/share/gccxml-0.9/GCC/2.95/cstdarg +12 -0
  17. data/share/gccxml-0.9/GCC/2.95/cstddef +13 -0
  18. data/share/gccxml-0.9/GCC/2.95/cstdio +55 -0
  19. data/share/gccxml-0.9/GCC/2.95/cstdlib +66 -0
  20. data/share/gccxml-0.9/GCC/2.95/cstring +34 -0
  21. data/share/gccxml-0.9/GCC/2.95/ctime +24 -0
  22. data/share/gccxml-0.9/GCC/2.95/cwchar +65 -0
  23. data/share/gccxml-0.9/GCC/2.95/cwctype +31 -0
  24. data/share/gccxml-0.9/GCC/2.95/deque +19 -0
  25. data/share/gccxml-0.9/GCC/2.95/exception +20 -0
  26. data/share/gccxml-0.9/GCC/2.95/fstream +23 -0
  27. data/share/gccxml-0.9/GCC/2.95/functional +64 -0
  28. data/share/gccxml-0.9/GCC/2.95/gccxml_bitset +1066 -0
  29. data/share/gccxml-0.9/GCC/2.95/iomanip +20 -0
  30. data/share/gccxml-0.9/GCC/2.95/iosfwd +20 -0
  31. data/share/gccxml-0.9/GCC/2.95/iostream +27 -0
  32. data/share/gccxml-0.9/GCC/2.95/iterator +39 -0
  33. data/share/gccxml-0.9/GCC/2.95/list +19 -0
  34. data/share/gccxml-0.9/GCC/2.95/map +20 -0
  35. data/share/gccxml-0.9/GCC/2.95/memory +21 -0
  36. data/share/gccxml-0.9/GCC/2.95/new +13 -0
  37. data/share/gccxml-0.9/GCC/2.95/numeric +15 -0
  38. data/share/gccxml-0.9/GCC/2.95/pthread.h +16 -0
  39. data/share/gccxml-0.9/GCC/2.95/queue +20 -0
  40. data/share/gccxml-0.9/GCC/2.95/set +20 -0
  41. data/share/gccxml-0.9/GCC/2.95/sstream +24 -0
  42. data/share/gccxml-0.9/GCC/2.95/stack +19 -0
  43. data/share/gccxml-0.9/GCC/2.95/std/bastring.cc +524 -0
  44. data/share/gccxml-0.9/GCC/2.95/std/complext.h +397 -0
  45. data/share/gccxml-0.9/GCC/2.95/std/dcomplex.h +92 -0
  46. data/share/gccxml-0.9/GCC/2.95/std/fcomplex.h +88 -0
  47. data/share/gccxml-0.9/GCC/2.95/std/gslice_array.h +170 -0
  48. data/share/gccxml-0.9/GCC/2.95/std/indirect_array.h +157 -0
  49. data/share/gccxml-0.9/GCC/2.95/std/ldcomplex.h +96 -0
  50. data/share/gccxml-0.9/GCC/2.95/std/mask_array.h +154 -0
  51. data/share/gccxml-0.9/GCC/2.95/std/slice_array.h +156 -0
  52. data/share/gccxml-0.9/GCC/2.95/std/std_valarray.h +728 -0
  53. data/share/gccxml-0.9/GCC/2.95/std/straits.h +162 -0
  54. data/share/gccxml-0.9/GCC/2.95/std/valarray_meta.h +1035 -0
  55. data/share/gccxml-0.9/GCC/2.95/stdexcept +17 -0
  56. data/share/gccxml-0.9/GCC/2.95/stl_alloc.h +1057 -0
  57. data/share/gccxml-0.9/GCC/2.95/stl_bvector.h +836 -0
  58. data/share/gccxml-0.9/GCC/2.95/stl_deque.h +1699 -0
  59. data/share/gccxml-0.9/GCC/2.95/stl_list.h +843 -0
  60. data/share/gccxml-0.9/GCC/2.95/stl_tree.h +1331 -0
  61. data/share/gccxml-0.9/GCC/2.95/stl_vector.h +828 -0
  62. data/share/gccxml-0.9/GCC/2.95/string +26 -0
  63. data/share/gccxml-0.9/GCC/2.95/strstream +23 -0
  64. data/share/gccxml-0.9/GCC/2.95/typeinfo +11 -0
  65. data/share/gccxml-0.9/GCC/2.95/utility +25 -0
  66. data/share/gccxml-0.9/GCC/2.95/valarray +52 -0
  67. data/share/gccxml-0.9/GCC/2.95/vector +19 -0
  68. data/share/gccxml-0.9/GCC/2.96/sstream +305 -0
  69. data/share/gccxml-0.9/GCC/3.0/pthread.h +16 -0
  70. data/share/gccxml-0.9/GCC/3.1/pthread.h +16 -0
  71. data/share/gccxml-0.9/GCC/3.2/bits/fstream.tcc +500 -0
  72. data/share/gccxml-0.9/GCC/3.2/bits/gthr-default.h +585 -0
  73. data/share/gccxml-0.9/GCC/3.2/bits/istream.tcc +1207 -0
  74. data/share/gccxml-0.9/GCC/3.2/bits/locale_facets.h +1810 -0
  75. data/share/gccxml-0.9/GCC/3.2/bits/locale_facets.tcc +2397 -0
  76. data/share/gccxml-0.9/GCC/3.2/bits/messages_members.h +108 -0
  77. data/share/gccxml-0.9/GCC/3.2/bits/ostream.tcc +713 -0
  78. data/share/gccxml-0.9/GCC/3.2/bits/sstream.tcc +241 -0
  79. data/share/gccxml-0.9/GCC/3.2/bits/stl_deque.h +1682 -0
  80. data/share/gccxml-0.9/GCC/3.2/bits/stl_list.h +989 -0
  81. data/share/gccxml-0.9/GCC/3.2/bits/stl_tree.h +1462 -0
  82. data/share/gccxml-0.9/GCC/3.2/bits/stl_vector.h +1085 -0
  83. data/share/gccxml-0.9/GCC/3.2/bits/valarray_meta.h +1063 -0
  84. data/share/gccxml-0.9/GCC/3.2/fstream +579 -0
  85. data/share/gccxml-0.9/GCC/3.2/pthread.h +16 -0
  86. data/share/gccxml-0.9/GCC/3.2/sstream +384 -0
  87. data/share/gccxml-0.9/GCC/3.3/bits/fstream.tcc +530 -0
  88. data/share/gccxml-0.9/GCC/3.3/bits/list.tcc +378 -0
  89. data/share/gccxml-0.9/GCC/3.3/bits/locale_facets.h +2050 -0
  90. data/share/gccxml-0.9/GCC/3.3/bits/messages_members.h +108 -0
  91. data/share/gccxml-0.9/GCC/3.3/bits/sstream.tcc +243 -0
  92. data/share/gccxml-0.9/GCC/3.3/bits/stl_deque.h +1603 -0
  93. data/share/gccxml-0.9/GCC/3.3/bits/stl_list.h +1167 -0
  94. data/share/gccxml-0.9/GCC/3.3/bits/stl_tree.h +1462 -0
  95. data/share/gccxml-0.9/GCC/3.3/bits/stl_vector.h +992 -0
  96. data/share/gccxml-0.9/GCC/3.3/bits/valarray_meta.h +1135 -0
  97. data/share/gccxml-0.9/GCC/3.3/fstream +842 -0
  98. data/share/gccxml-0.9/GCC/3.3/gccxml_builtins.h +22 -0
  99. data/share/gccxml-0.9/GCC/3.3/sstream +638 -0
  100. data/share/gccxml-0.9/GCC/3.4/bits/gthr-default.h +669 -0
  101. data/share/gccxml-0.9/GCC/3.4/gccxml_builtins.h +91 -0
  102. data/share/gccxml-0.9/GCC/4.0/emmintrin.h +5 -0
  103. data/share/gccxml-0.9/GCC/4.0/gccxml_apple_emmintrin.h +1037 -0
  104. data/share/gccxml-0.9/GCC/4.0/gccxml_apple_mmintrin.h +669 -0
  105. data/share/gccxml-0.9/GCC/4.0/gccxml_apple_xmmintrin.h +870 -0
  106. data/share/gccxml-0.9/GCC/4.0/gccxml_builtins.h +128 -0
  107. data/share/gccxml-0.9/GCC/4.0/gccxml_gnu_emmintrin.h +977 -0
  108. data/share/gccxml-0.9/GCC/4.0/gccxml_gnu_mmintrin.h +636 -0
  109. data/share/gccxml-0.9/GCC/4.0/gccxml_gnu_xmmintrin.h +833 -0
  110. data/share/gccxml-0.9/GCC/4.0/mmintrin.h +5 -0
  111. data/share/gccxml-0.9/GCC/4.0/xmmintrin.h +5 -0
  112. data/share/gccxml-0.9/GCC/4.1/bits/gthr-default.h +622 -0
  113. data/share/gccxml-0.9/GCC/4.1/emmintrin.h +5 -0
  114. data/share/gccxml-0.9/GCC/4.1/gccxml_apple_emmintrin.h +1509 -0
  115. data/share/gccxml-0.9/GCC/4.1/gccxml_apple_mmintrin.h +942 -0
  116. data/share/gccxml-0.9/GCC/4.1/gccxml_apple_xmmintrin.h +1192 -0
  117. data/share/gccxml-0.9/GCC/4.1/gccxml_builtins.h +131 -0
  118. data/share/gccxml-0.9/GCC/4.1/gccxml_gnu_emmintrin.h +1004 -0
  119. data/share/gccxml-0.9/GCC/4.1/gccxml_gnu_mmintrin.h +637 -0
  120. data/share/gccxml-0.9/GCC/4.1/gccxml_gnu_xmmintrin.h +834 -0
  121. data/share/gccxml-0.9/GCC/4.1/mmintrin.h +5 -0
  122. data/share/gccxml-0.9/GCC/4.1/xmmintrin.h +5 -0
  123. data/share/gccxml-0.9/GCC/4.2/emmintrin.h +5 -0
  124. data/share/gccxml-0.9/GCC/4.2/gccxml_apple_emmintrin.h +1509 -0
  125. data/share/gccxml-0.9/GCC/4.2/gccxml_apple_mmintrin.h +942 -0
  126. data/share/gccxml-0.9/GCC/4.2/gccxml_apple_xmmintrin.h +1192 -0
  127. data/share/gccxml-0.9/GCC/4.2/gccxml_builtins.h +131 -0
  128. data/share/gccxml-0.9/GCC/4.2/gccxml_gnu_emmintrin.h +1013 -0
  129. data/share/gccxml-0.9/GCC/4.2/gccxml_gnu_mmintrin.h +663 -0
  130. data/share/gccxml-0.9/GCC/4.2/gccxml_gnu_xmmintrin.h +860 -0
  131. data/share/gccxml-0.9/GCC/4.2/mmintrin.h +5 -0
  132. data/share/gccxml-0.9/GCC/4.2/xmmintrin.h +5 -0
  133. data/share/gccxml-0.9/GCC/4.3/emmintrin.h +1043 -0
  134. data/share/gccxml-0.9/GCC/4.3/gccxml_builtins.h +183 -0
  135. data/share/gccxml-0.9/GCC/4.3/mmintrin.h +663 -0
  136. data/share/gccxml-0.9/GCC/4.3/xmmintrin.h +867 -0
  137. data/share/gccxml-0.9/GCC/4.4/bits/c++config.h +1431 -0
  138. data/share/gccxml-0.9/GCC/4.4/emmintrin.h +1041 -0
  139. data/share/gccxml-0.9/GCC/4.4/gccxml_builtins.h +153 -0
  140. data/share/gccxml-0.9/GCC/4.4/mmintrin.h +662 -0
  141. data/share/gccxml-0.9/GCC/4.4/xmmintrin.h +864 -0
  142. data/share/gccxml-0.9/GCC/4.5/gccxml_builtins.h +154 -0
  143. data/share/gccxml-0.9/GCC/4.5/iomanip +349 -0
  144. data/share/gccxml-0.9/GCC/COPYING.RUNTIME +73 -0
  145. data/share/gccxml-0.9/GCC/COPYING3 +674 -0
  146. data/share/gccxml-0.9/IBM/8.0/adapt_headers.sh +34 -0
  147. data/share/gccxml-0.9/IBM/8.0/stdlib.h.patch +27 -0
  148. data/share/gccxml-0.9/IBM/8.0/xstring.patch +19 -0
  149. data/share/gccxml-0.9/IBM/README +8 -0
  150. data/share/gccxml-0.9/IBM/find_flags +51 -0
  151. data/share/gccxml-0.9/IBM/find_flags_common +48 -0
  152. data/share/gccxml-0.9/Intel/find_flags +56 -0
  153. data/share/gccxml-0.9/Intel/pthread.h +16 -0
  154. data/share/gccxml-0.9/MIPSpro/7.3/exception +9 -0
  155. data/share/gccxml-0.9/MIPSpro/7.3/gccxml_mpro_internals.h +21 -0
  156. data/share/gccxml-0.9/MIPSpro/7.3/iomanip +161 -0
  157. data/share/gccxml-0.9/MIPSpro/7.3/ostream +9 -0
  158. data/share/gccxml-0.9/MIPSpro/7.3/stddef.h +9 -0
  159. data/share/gccxml-0.9/MIPSpro/7.3/stl_config.h +9 -0
  160. data/share/gccxml-0.9/MIPSpro/7.3/stl_locale.h +17 -0
  161. data/share/gccxml-0.9/MIPSpro/7.3/stl_monetary.h +14 -0
  162. data/share/gccxml-0.9/MIPSpro/7.3/stl_numeric_facets.h +13 -0
  163. data/share/gccxml-0.9/MIPSpro/7.3/stl_threads.h +11 -0
  164. data/share/gccxml-0.9/MIPSpro/7.3/string +18 -0
  165. data/share/gccxml-0.9/MIPSpro/find_flags +70 -0
  166. data/share/gccxml-0.9/MIPSpro/mipspro_defs.cxx +63 -0
  167. data/share/gccxml-0.9/Sun/5.8/Cstd.patch +156 -0
  168. data/share/gccxml-0.9/Sun/5.8/adapt_headers.sh +32 -0
  169. data/share/gccxml-0.9/Sun/5.8/std-5.10.patch +22 -0
  170. data/share/gccxml-0.9/Sun/README +8 -0
  171. data/share/gccxml-0.9/Sun/find_flags +51 -0
  172. data/share/gccxml-0.9/Sun/find_flags_common +42 -0
  173. data/share/gccxml-0.9/gccxml_config +2 -0
  174. data/share/gccxml-0.9/gccxml_identify_compiler.cc +13 -0
  175. data/share/man/man1/gccxml.1 +246 -0
  176. metadata +245 -0
@@ -0,0 +1,1331 @@
1
+ /*
2
+ *
3
+ * Copyright (c) 1996,1997
4
+ * Silicon Graphics Computer Systems, Inc.
5
+ *
6
+ * Permission to use, copy, modify, distribute and sell this software
7
+ * and its documentation for any purpose is hereby granted without fee,
8
+ * provided that the above copyright notice appear in all copies and
9
+ * that both that copyright notice and this permission notice appear
10
+ * in supporting documentation. Silicon Graphics makes no
11
+ * representations about the suitability of this software for any
12
+ * purpose. It is provided "as is" without express or implied warranty.
13
+ *
14
+ *
15
+ * Copyright (c) 1994
16
+ * Hewlett-Packard Company
17
+ *
18
+ * Permission to use, copy, modify, distribute and sell this software
19
+ * and its documentation for any purpose is hereby granted without fee,
20
+ * provided that the above copyright notice appear in all copies and
21
+ * that both that copyright notice and this permission notice appear
22
+ * in supporting documentation. Hewlett-Packard Company makes no
23
+ * representations about the suitability of this software for any
24
+ * purpose. It is provided "as is" without express or implied warranty.
25
+ *
26
+ *
27
+ */
28
+
29
+ /* NOTE: This is an internal header file, included by other STL headers.
30
+ * You should not attempt to use it directly.
31
+ */
32
+
33
+ #ifndef __SGI_STL_INTERNAL_TREE_H
34
+ #define __SGI_STL_INTERNAL_TREE_H
35
+
36
+ /*
37
+
38
+ Red-black tree class, designed for use in implementing STL
39
+ associative containers (set, multiset, map, and multimap). The
40
+ insertion and deletion algorithms are based on those in Cormen,
41
+ Leiserson, and Rivest, Introduction to Algorithms (MIT Press, 1990),
42
+ except that
43
+
44
+ (1) the header cell is maintained with links not only to the root
45
+ but also to the leftmost node of the tree, to enable constant time
46
+ begin(), and to the rightmost node of the tree, to enable linear time
47
+ performance when used with the generic set algorithms (set_union,
48
+ etc.);
49
+
50
+ (2) when a node being deleted has two children its successor node is
51
+ relinked into its place, rather than copied, so that the only
52
+ iterators invalidated are those referring to the deleted node.
53
+
54
+ */
55
+
56
+ #include <stl_algobase.h>
57
+ #include <stl_alloc.h>
58
+ #include <stl_construct.h>
59
+ #include <stl_function.h>
60
+
61
+ __STL_BEGIN_NAMESPACE
62
+
63
+ #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
64
+ #pragma set woff 1375
65
+ #endif
66
+
67
+ typedef bool _Rb_tree_Color_type;
68
+ const _Rb_tree_Color_type _S_rb_tree_red = false;
69
+ const _Rb_tree_Color_type _S_rb_tree_black = true;
70
+
71
+ struct _Rb_tree_node_base
72
+ {
73
+ typedef _Rb_tree_Color_type _Color_type;
74
+ typedef _Rb_tree_node_base* _Base_ptr;
75
+
76
+ _Color_type _M_color;
77
+ _Base_ptr _M_parent;
78
+ _Base_ptr _M_left;
79
+ _Base_ptr _M_right;
80
+
81
+ static _Base_ptr _S_minimum(_Base_ptr __x)
82
+ {
83
+ while (__x->_M_left != 0) __x = __x->_M_left;
84
+ return __x;
85
+ }
86
+
87
+ static _Base_ptr _S_maximum(_Base_ptr __x)
88
+ {
89
+ while (__x->_M_right != 0) __x = __x->_M_right;
90
+ return __x;
91
+ }
92
+ };
93
+
94
+ template <class _Value>
95
+ struct _Rb_tree_node : public _Rb_tree_node_base
96
+ {
97
+ typedef _Rb_tree_node<_Value>* _Link_type;
98
+ _Value _M_value_field;
99
+ };
100
+
101
+
102
+ struct _Rb_tree_base_iterator
103
+ {
104
+ typedef _Rb_tree_node_base::_Base_ptr _Base_ptr;
105
+ typedef bidirectional_iterator_tag iterator_category;
106
+ typedef ptrdiff_t difference_type;
107
+ _Base_ptr _M_node;
108
+
109
+ void _M_increment()
110
+ {
111
+ if (_M_node->_M_right != 0) {
112
+ _M_node = _M_node->_M_right;
113
+ while (_M_node->_M_left != 0)
114
+ _M_node = _M_node->_M_left;
115
+ }
116
+ else {
117
+ _Base_ptr __y = _M_node->_M_parent;
118
+ while (_M_node == __y->_M_right) {
119
+ _M_node = __y;
120
+ __y = __y->_M_parent;
121
+ }
122
+ if (_M_node->_M_right != __y)
123
+ _M_node = __y;
124
+ }
125
+ }
126
+
127
+ void _M_decrement()
128
+ {
129
+ if (_M_node->_M_color == _S_rb_tree_red &&
130
+ _M_node->_M_parent->_M_parent == _M_node)
131
+ _M_node = _M_node->_M_right;
132
+ else if (_M_node->_M_left != 0) {
133
+ _Base_ptr __y = _M_node->_M_left;
134
+ while (__y->_M_right != 0)
135
+ __y = __y->_M_right;
136
+ _M_node = __y;
137
+ }
138
+ else {
139
+ _Base_ptr __y = _M_node->_M_parent;
140
+ while (_M_node == __y->_M_left) {
141
+ _M_node = __y;
142
+ __y = __y->_M_parent;
143
+ }
144
+ _M_node = __y;
145
+ }
146
+ }
147
+ };
148
+
149
+ template <class _Value, class _Ref, class _Ptr>
150
+ struct _Rb_tree_iterator : public _Rb_tree_base_iterator
151
+ {
152
+ typedef _Value value_type;
153
+ typedef _Ref reference;
154
+ typedef _Ptr pointer;
155
+ typedef _Rb_tree_iterator<_Value, _Value&, _Value*>
156
+ iterator;
157
+ typedef _Rb_tree_iterator<_Value, const _Value&, const _Value*>
158
+ const_iterator;
159
+ typedef _Rb_tree_iterator<_Value, _Ref, _Ptr>
160
+ _Self;
161
+ typedef _Rb_tree_node<_Value>* _Link_type;
162
+
163
+ _Rb_tree_iterator() {}
164
+ _Rb_tree_iterator(_Link_type __x) { _M_node = __x; }
165
+ _Rb_tree_iterator(const iterator& __it) { _M_node = __it._M_node; }
166
+
167
+ reference operator*() const { return _Link_type(_M_node)->_M_value_field; }
168
+ #ifndef __SGI_STL_NO_ARROW_OPERATOR
169
+ pointer operator->() const { return &(operator*()); }
170
+ #endif /* __SGI_STL_NO_ARROW_OPERATOR */
171
+
172
+ _Self& operator++() { _M_increment(); return *this; }
173
+ _Self operator++(int) {
174
+ _Self __tmp = *this;
175
+ _M_increment();
176
+ return __tmp;
177
+ }
178
+
179
+ _Self& operator--() { _M_decrement(); return *this; }
180
+ _Self operator--(int) {
181
+ _Self __tmp = *this;
182
+ _M_decrement();
183
+ return __tmp;
184
+ }
185
+ };
186
+
187
+ inline bool operator==(const _Rb_tree_base_iterator& __x,
188
+ const _Rb_tree_base_iterator& __y) {
189
+ return __x._M_node == __y._M_node;
190
+ }
191
+
192
+ inline bool operator!=(const _Rb_tree_base_iterator& __x,
193
+ const _Rb_tree_base_iterator& __y) {
194
+ return __x._M_node != __y._M_node;
195
+ }
196
+
197
+ #ifndef __STL_CLASS_PARTIAL_SPECIALIZATION
198
+
199
+ inline bidirectional_iterator_tag
200
+ iterator_category(const _Rb_tree_base_iterator&) {
201
+ return bidirectional_iterator_tag();
202
+ }
203
+
204
+ inline _Rb_tree_base_iterator::difference_type*
205
+ distance_type(const _Rb_tree_base_iterator&) {
206
+ return (_Rb_tree_base_iterator::difference_type*) 0;
207
+ }
208
+
209
+ template <class _Value, class _Ref, class _Ptr>
210
+ inline _Value* value_type(const _Rb_tree_iterator<_Value, _Ref, _Ptr>&) {
211
+ return (_Value*) 0;
212
+ }
213
+
214
+ #endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */
215
+
216
+ inline void
217
+ _Rb_tree_rotate_left(_Rb_tree_node_base* __x, _Rb_tree_node_base*& __root)
218
+ {
219
+ _Rb_tree_node_base* __y = __x->_M_right;
220
+ __x->_M_right = __y->_M_left;
221
+ if (__y->_M_left !=0)
222
+ __y->_M_left->_M_parent = __x;
223
+ __y->_M_parent = __x->_M_parent;
224
+
225
+ if (__x == __root)
226
+ __root = __y;
227
+ else if (__x == __x->_M_parent->_M_left)
228
+ __x->_M_parent->_M_left = __y;
229
+ else
230
+ __x->_M_parent->_M_right = __y;
231
+ __y->_M_left = __x;
232
+ __x->_M_parent = __y;
233
+ }
234
+
235
+ inline void
236
+ _Rb_tree_rotate_right(_Rb_tree_node_base* __x, _Rb_tree_node_base*& __root)
237
+ {
238
+ _Rb_tree_node_base* __y = __x->_M_left;
239
+ __x->_M_left = __y->_M_right;
240
+ if (__y->_M_right != 0)
241
+ __y->_M_right->_M_parent = __x;
242
+ __y->_M_parent = __x->_M_parent;
243
+
244
+ if (__x == __root)
245
+ __root = __y;
246
+ else if (__x == __x->_M_parent->_M_right)
247
+ __x->_M_parent->_M_right = __y;
248
+ else
249
+ __x->_M_parent->_M_left = __y;
250
+ __y->_M_right = __x;
251
+ __x->_M_parent = __y;
252
+ }
253
+
254
+ inline void
255
+ _Rb_tree_rebalance(_Rb_tree_node_base* __x, _Rb_tree_node_base*& __root)
256
+ {
257
+ __x->_M_color = _S_rb_tree_red;
258
+ while (__x != __root && __x->_M_parent->_M_color == _S_rb_tree_red) {
259
+ if (__x->_M_parent == __x->_M_parent->_M_parent->_M_left) {
260
+ _Rb_tree_node_base* __y = __x->_M_parent->_M_parent->_M_right;
261
+ if (__y && __y->_M_color == _S_rb_tree_red) {
262
+ __x->_M_parent->_M_color = _S_rb_tree_black;
263
+ __y->_M_color = _S_rb_tree_black;
264
+ __x->_M_parent->_M_parent->_M_color = _S_rb_tree_red;
265
+ __x = __x->_M_parent->_M_parent;
266
+ }
267
+ else {
268
+ if (__x == __x->_M_parent->_M_right) {
269
+ __x = __x->_M_parent;
270
+ _Rb_tree_rotate_left(__x, __root);
271
+ }
272
+ __x->_M_parent->_M_color = _S_rb_tree_black;
273
+ __x->_M_parent->_M_parent->_M_color = _S_rb_tree_red;
274
+ _Rb_tree_rotate_right(__x->_M_parent->_M_parent, __root);
275
+ }
276
+ }
277
+ else {
278
+ _Rb_tree_node_base* __y = __x->_M_parent->_M_parent->_M_left;
279
+ if (__y && __y->_M_color == _S_rb_tree_red) {
280
+ __x->_M_parent->_M_color = _S_rb_tree_black;
281
+ __y->_M_color = _S_rb_tree_black;
282
+ __x->_M_parent->_M_parent->_M_color = _S_rb_tree_red;
283
+ __x = __x->_M_parent->_M_parent;
284
+ }
285
+ else {
286
+ if (__x == __x->_M_parent->_M_left) {
287
+ __x = __x->_M_parent;
288
+ _Rb_tree_rotate_right(__x, __root);
289
+ }
290
+ __x->_M_parent->_M_color = _S_rb_tree_black;
291
+ __x->_M_parent->_M_parent->_M_color = _S_rb_tree_red;
292
+ _Rb_tree_rotate_left(__x->_M_parent->_M_parent, __root);
293
+ }
294
+ }
295
+ }
296
+ __root->_M_color = _S_rb_tree_black;
297
+ }
298
+
299
+ inline _Rb_tree_node_base*
300
+ _Rb_tree_rebalance_for_erase(_Rb_tree_node_base* __z,
301
+ _Rb_tree_node_base*& __root,
302
+ _Rb_tree_node_base*& __leftmost,
303
+ _Rb_tree_node_base*& __rightmost)
304
+ {
305
+ _Rb_tree_node_base* __y = __z;
306
+ _Rb_tree_node_base* __x = 0;
307
+ _Rb_tree_node_base* __x_parent = 0;
308
+ if (__y->_M_left == 0) // __z has at most one non-null child. y == z.
309
+ __x = __y->_M_right; // __x might be null.
310
+ else
311
+ if (__y->_M_right == 0) // __z has exactly one non-null child. y == z.
312
+ __x = __y->_M_left; // __x is not null.
313
+ else { // __z has two non-null children. Set __y to
314
+ __y = __y->_M_right; // __z's successor. __x might be null.
315
+ while (__y->_M_left != 0)
316
+ __y = __y->_M_left;
317
+ __x = __y->_M_right;
318
+ }
319
+ if (__y != __z) { // relink y in place of z. y is z's successor
320
+ __z->_M_left->_M_parent = __y;
321
+ __y->_M_left = __z->_M_left;
322
+ if (__y != __z->_M_right) {
323
+ __x_parent = __y->_M_parent;
324
+ if (__x) __x->_M_parent = __y->_M_parent;
325
+ __y->_M_parent->_M_left = __x; // __y must be a child of _M_left
326
+ __y->_M_right = __z->_M_right;
327
+ __z->_M_right->_M_parent = __y;
328
+ }
329
+ else
330
+ __x_parent = __y;
331
+ if (__root == __z)
332
+ __root = __y;
333
+ else if (__z->_M_parent->_M_left == __z)
334
+ __z->_M_parent->_M_left = __y;
335
+ else
336
+ __z->_M_parent->_M_right = __y;
337
+ __y->_M_parent = __z->_M_parent;
338
+ __STD::swap(__y->_M_color, __z->_M_color);
339
+ __y = __z;
340
+ // __y now points to node to be actually deleted
341
+ }
342
+ else { // __y == __z
343
+ __x_parent = __y->_M_parent;
344
+ if (__x) __x->_M_parent = __y->_M_parent;
345
+ if (__root == __z)
346
+ __root = __x;
347
+ else
348
+ if (__z->_M_parent->_M_left == __z)
349
+ __z->_M_parent->_M_left = __x;
350
+ else
351
+ __z->_M_parent->_M_right = __x;
352
+ if (__leftmost == __z)
353
+ if (__z->_M_right == 0) // __z->_M_left must be null also
354
+ __leftmost = __z->_M_parent;
355
+ // makes __leftmost == _M_header if __z == __root
356
+ else
357
+ __leftmost = _Rb_tree_node_base::_S_minimum(__x);
358
+ if (__rightmost == __z)
359
+ if (__z->_M_left == 0) // __z->_M_right must be null also
360
+ __rightmost = __z->_M_parent;
361
+ // makes __rightmost == _M_header if __z == __root
362
+ else // __x == __z->_M_left
363
+ __rightmost = _Rb_tree_node_base::_S_maximum(__x);
364
+ }
365
+ if (__y->_M_color != _S_rb_tree_red) {
366
+ while (__x != __root && (__x == 0 || __x->_M_color == _S_rb_tree_black))
367
+ if (__x == __x_parent->_M_left) {
368
+ _Rb_tree_node_base* __w = __x_parent->_M_right;
369
+ if (__w->_M_color == _S_rb_tree_red) {
370
+ __w->_M_color = _S_rb_tree_black;
371
+ __x_parent->_M_color = _S_rb_tree_red;
372
+ _Rb_tree_rotate_left(__x_parent, __root);
373
+ __w = __x_parent->_M_right;
374
+ }
375
+ if ((__w->_M_left == 0 ||
376
+ __w->_M_left->_M_color == _S_rb_tree_black) &&
377
+ (__w->_M_right == 0 ||
378
+ __w->_M_right->_M_color == _S_rb_tree_black)) {
379
+ __w->_M_color = _S_rb_tree_red;
380
+ __x = __x_parent;
381
+ __x_parent = __x_parent->_M_parent;
382
+ } else {
383
+ if (__w->_M_right == 0 ||
384
+ __w->_M_right->_M_color == _S_rb_tree_black) {
385
+ if (__w->_M_left) __w->_M_left->_M_color = _S_rb_tree_black;
386
+ __w->_M_color = _S_rb_tree_red;
387
+ _Rb_tree_rotate_right(__w, __root);
388
+ __w = __x_parent->_M_right;
389
+ }
390
+ __w->_M_color = __x_parent->_M_color;
391
+ __x_parent->_M_color = _S_rb_tree_black;
392
+ if (__w->_M_right) __w->_M_right->_M_color = _S_rb_tree_black;
393
+ _Rb_tree_rotate_left(__x_parent, __root);
394
+ break;
395
+ }
396
+ } else { // same as above, with _M_right <-> _M_left.
397
+ _Rb_tree_node_base* __w = __x_parent->_M_left;
398
+ if (__w->_M_color == _S_rb_tree_red) {
399
+ __w->_M_color = _S_rb_tree_black;
400
+ __x_parent->_M_color = _S_rb_tree_red;
401
+ _Rb_tree_rotate_right(__x_parent, __root);
402
+ __w = __x_parent->_M_left;
403
+ }
404
+ if ((__w->_M_right == 0 ||
405
+ __w->_M_right->_M_color == _S_rb_tree_black) &&
406
+ (__w->_M_left == 0 ||
407
+ __w->_M_left->_M_color == _S_rb_tree_black)) {
408
+ __w->_M_color = _S_rb_tree_red;
409
+ __x = __x_parent;
410
+ __x_parent = __x_parent->_M_parent;
411
+ } else {
412
+ if (__w->_M_left == 0 ||
413
+ __w->_M_left->_M_color == _S_rb_tree_black) {
414
+ if (__w->_M_right) __w->_M_right->_M_color = _S_rb_tree_black;
415
+ __w->_M_color = _S_rb_tree_red;
416
+ _Rb_tree_rotate_left(__w, __root);
417
+ __w = __x_parent->_M_left;
418
+ }
419
+ __w->_M_color = __x_parent->_M_color;
420
+ __x_parent->_M_color = _S_rb_tree_black;
421
+ if (__w->_M_left) __w->_M_left->_M_color = _S_rb_tree_black;
422
+ _Rb_tree_rotate_right(__x_parent, __root);
423
+ break;
424
+ }
425
+ }
426
+ if (__x) __x->_M_color = _S_rb_tree_black;
427
+ }
428
+ return __y;
429
+ }
430
+
431
+ // Base class to encapsulate the differences between old SGI-style
432
+ // allocators and standard-conforming allocators. In order to avoid
433
+ // having an empty base class, we arbitrarily move one of rb_tree's
434
+ // data members into the base class.
435
+
436
+ #ifdef __STL_USE_STD_ALLOCATORS
437
+
438
+ // _Base for general standard-conforming allocators.
439
+ template <class _Tp, class _Alloc, bool _S_instanceless>
440
+ class _Rb_tree_alloc_base {
441
+ public:
442
+ typedef typename _Alloc_traits<_Tp, _Alloc>::allocator_type allocator_type;
443
+ allocator_type get_allocator() const { return _M_node_allocator; }
444
+
445
+ _Rb_tree_alloc_base(const allocator_type& __a)
446
+ : _M_node_allocator(__a), _M_header(0) {}
447
+
448
+ protected:
449
+ typename _Alloc_traits<_Rb_tree_node<_Tp>, _Alloc>::allocator_type
450
+ _M_node_allocator;
451
+ _Rb_tree_node<_Tp>* _M_header;
452
+
453
+ _Rb_tree_node<_Tp>* _M_get_node()
454
+ { return _M_node_allocator.allocate(1); }
455
+ void _M_put_node(_Rb_tree_node<_Tp>* __p)
456
+ { _M_node_allocator.deallocate(__p, 1); }
457
+ };
458
+
459
+ // Specialization for instanceless allocators.
460
+ template <class _Tp, class _Alloc>
461
+ class _Rb_tree_alloc_base<_Tp, _Alloc, true> {
462
+ public:
463
+ typedef typename _Alloc_traits<_Tp, _Alloc>::allocator_type allocator_type;
464
+ allocator_type get_allocator() const { return allocator_type(); }
465
+
466
+ _Rb_tree_alloc_base(const allocator_type&) : _M_header(0) {}
467
+
468
+ protected:
469
+ _Rb_tree_node<_Tp>* _M_header;
470
+
471
+ typedef typename _Alloc_traits<_Rb_tree_node<_Tp>, _Alloc>::_Alloc_type
472
+ _Alloc_type;
473
+
474
+ _Rb_tree_node<_Tp>* _M_get_node()
475
+ { return _Alloc_type::allocate(1); }
476
+ void _M_put_node(_Rb_tree_node<_Tp>* __p)
477
+ { _Alloc_type::deallocate(__p, 1); }
478
+ };
479
+
480
+ template <class _Tp, class _Alloc>
481
+ struct _Rb_tree_base
482
+ : public _Rb_tree_alloc_base<_Tp, _Alloc,
483
+ _Alloc_traits<_Tp, _Alloc>::_S_instanceless>
484
+ {
485
+ typedef _Rb_tree_alloc_base<_Tp, _Alloc,
486
+ _Alloc_traits<_Tp, _Alloc>::_S_instanceless>
487
+ _Base;
488
+ typedef typename _Base::allocator_type allocator_type;
489
+
490
+ _Rb_tree_base(const allocator_type& __a)
491
+ : _Base(__a) { this->_M_header = this->_M_get_node(); }
492
+ ~_Rb_tree_base() { this->_M_put_node(this->_M_header); }
493
+
494
+ };
495
+
496
+ #else /* __STL_USE_STD_ALLOCATORS */
497
+
498
+ template <class _Tp, class _Alloc>
499
+ struct _Rb_tree_base
500
+ {
501
+ typedef _Alloc allocator_type;
502
+ allocator_type get_allocator() const { return allocator_type(); }
503
+
504
+ _Rb_tree_base(const allocator_type&)
505
+ : _M_header(0) { this->_M_header = this->_M_get_node(); }
506
+ ~_Rb_tree_base() { this->_M_put_node(this->_M_header); }
507
+
508
+ protected:
509
+ _Rb_tree_node<_Tp>* _M_header;
510
+
511
+ typedef simple_alloc<_Rb_tree_node<_Tp>, _Alloc> _Alloc_type;
512
+
513
+ _Rb_tree_node<_Tp>* _M_get_node()
514
+ { return _Alloc_type::allocate(1); }
515
+ void _M_put_node(_Rb_tree_node<_Tp>* __p)
516
+ { _Alloc_type::deallocate(__p, 1); }
517
+ };
518
+
519
+ #endif /* __STL_USE_STD_ALLOCATORS */
520
+
521
+ template <class _Key, class _Value, class _KeyOfValue, class _Compare,
522
+ class _Alloc = __STL_DEFAULT_ALLOCATOR(_Value) >
523
+ class _Rb_tree : protected _Rb_tree_base<_Value, _Alloc> {
524
+ typedef _Rb_tree_base<_Value, _Alloc> _Base;
525
+ protected:
526
+ typedef _Rb_tree_node_base* _Base_ptr;
527
+ typedef _Rb_tree_node<_Value> _Rb_tree_node;
528
+ typedef _Rb_tree_Color_type _Color_type;
529
+ public:
530
+ typedef _Key key_type;
531
+ typedef _Value value_type;
532
+ typedef value_type* pointer;
533
+ typedef const value_type* const_pointer;
534
+ typedef value_type& reference;
535
+ typedef const value_type& const_reference;
536
+ typedef _Rb_tree_node* _Link_type;
537
+ typedef size_t size_type;
538
+ typedef ptrdiff_t difference_type;
539
+
540
+ typedef typename _Base::allocator_type allocator_type;
541
+ allocator_type get_allocator() const { return _Base::get_allocator(); }
542
+
543
+ protected:
544
+ using _Base::_M_get_node;
545
+ using _Base::_M_put_node;
546
+ using _Base::_M_header;
547
+
548
+ protected:
549
+
550
+ _Link_type _M_create_node(const value_type& __x)
551
+ {
552
+ _Link_type __tmp = _M_get_node();
553
+ __STL_TRY {
554
+ construct(&__tmp->_M_value_field, __x);
555
+ }
556
+ __STL_UNWIND(_M_put_node(__tmp));
557
+ return __tmp;
558
+ }
559
+
560
+ _Link_type _M_clone_node(_Link_type __x)
561
+ {
562
+ _Link_type __tmp = _M_create_node(__x->_M_value_field);
563
+ __tmp->_M_color = __x->_M_color;
564
+ __tmp->_M_left = 0;
565
+ __tmp->_M_right = 0;
566
+ return __tmp;
567
+ }
568
+
569
+ void destroy_node(_Link_type __p)
570
+ {
571
+ destroy(&__p->_M_value_field);
572
+ _M_put_node(__p);
573
+ }
574
+
575
+ protected:
576
+ size_type _M_node_count; // keeps track of size of tree
577
+ _Compare _M_key_compare;
578
+
579
+ _Link_type& _M_root() const
580
+ { return (_Link_type&) _M_header->_M_parent; }
581
+ _Link_type& _M_leftmost() const
582
+ { return (_Link_type&) _M_header->_M_left; }
583
+ _Link_type& _M_rightmost() const
584
+ { return (_Link_type&) _M_header->_M_right; }
585
+
586
+ static _Link_type& _S_left(_Link_type __x)
587
+ { return (_Link_type&)(__x->_M_left); }
588
+ static _Link_type& _S_right(_Link_type __x)
589
+ { return (_Link_type&)(__x->_M_right); }
590
+ static _Link_type& _S_parent(_Link_type __x)
591
+ { return (_Link_type&)(__x->_M_parent); }
592
+ static reference _S_value(_Link_type __x)
593
+ { return __x->_M_value_field; }
594
+ static const _Key& _S_key(_Link_type __x)
595
+ { return _KeyOfValue()(_S_value(__x)); }
596
+ static _Color_type& _S_color(_Link_type __x)
597
+ { return (_Color_type&)(__x->_M_color); }
598
+
599
+ static _Link_type& _S_left(_Base_ptr __x)
600
+ { return (_Link_type&)(__x->_M_left); }
601
+ static _Link_type& _S_right(_Base_ptr __x)
602
+ { return (_Link_type&)(__x->_M_right); }
603
+ static _Link_type& _S_parent(_Base_ptr __x)
604
+ { return (_Link_type&)(__x->_M_parent); }
605
+ static reference _S_value(_Base_ptr __x)
606
+ { return ((_Link_type)__x)->_M_value_field; }
607
+ static const _Key& _S_key(_Base_ptr __x)
608
+ { return _KeyOfValue()(_S_value(_Link_type(__x)));}
609
+ static _Color_type& _S_color(_Base_ptr __x)
610
+ { return (_Color_type&)(_Link_type(__x)->_M_color); }
611
+
612
+ static _Link_type _S_minimum(_Link_type __x)
613
+ { return (_Link_type) _Rb_tree_node_base::_S_minimum(__x); }
614
+
615
+ static _Link_type _S_maximum(_Link_type __x)
616
+ { return (_Link_type) _Rb_tree_node_base::_S_maximum(__x); }
617
+
618
+ public:
619
+ typedef _Rb_tree_iterator<value_type, reference, pointer> iterator;
620
+ typedef _Rb_tree_iterator<value_type, const_reference, const_pointer>
621
+ const_iterator;
622
+
623
+ #ifdef __STL_CLASS_PARTIAL_SPECIALIZATION
624
+ typedef reverse_iterator<const_iterator> const_reverse_iterator;
625
+ typedef reverse_iterator<iterator> reverse_iterator;
626
+ #else /* __STL_CLASS_PARTIAL_SPECIALIZATION */
627
+ typedef reverse_bidirectional_iterator<iterator, value_type, reference,
628
+ difference_type>
629
+ reverse_iterator;
630
+ typedef reverse_bidirectional_iterator<const_iterator, value_type,
631
+ const_reference, difference_type>
632
+ const_reverse_iterator;
633
+ #endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */
634
+
635
+ private:
636
+ iterator _M_insert(_Base_ptr __x, _Base_ptr __y, const value_type& __v);
637
+ _Link_type _M_copy(_Link_type __x, _Link_type __p);
638
+ void _M_erase(_Link_type __x);
639
+
640
+ public:
641
+ // allocation/deallocation
642
+ _Rb_tree()
643
+ : _Base(allocator_type()), _M_node_count(0), _M_key_compare()
644
+ { _M_empty_initialize(); }
645
+
646
+ _Rb_tree(const _Compare& __comp)
647
+ : _Base(allocator_type()), _M_node_count(0), _M_key_compare(__comp)
648
+ { _M_empty_initialize(); }
649
+
650
+ _Rb_tree(const _Compare& __comp, const allocator_type& __a)
651
+ : _Base(__a), _M_node_count(0), _M_key_compare(__comp)
652
+ { _M_empty_initialize(); }
653
+
654
+ _Rb_tree(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x)
655
+ : _Base(__x.get_allocator()),
656
+ _M_node_count(0), _M_key_compare(__x._M_key_compare)
657
+ {
658
+ if (__x._M_root() == 0)
659
+ _M_empty_initialize();
660
+ else {
661
+ _S_color(_M_header) = _S_rb_tree_red;
662
+ _M_root() = _M_copy(__x._M_root(), _M_header);
663
+ _M_leftmost() = _S_minimum(_M_root());
664
+ _M_rightmost() = _S_maximum(_M_root());
665
+ }
666
+ _M_node_count = __x._M_node_count;
667
+ }
668
+ ~_Rb_tree() { clear(); }
669
+ _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>&
670
+ operator=(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x);
671
+
672
+ private:
673
+ void _M_empty_initialize() {
674
+ _S_color(_M_header) = _S_rb_tree_red; // used to distinguish header from
675
+ // __root, in iterator.operator++
676
+ _M_root() = 0;
677
+ _M_leftmost() = _M_header;
678
+ _M_rightmost() = _M_header;
679
+ }
680
+
681
+ public:
682
+ // accessors:
683
+ _Compare key_comp() const { return _M_key_compare; }
684
+ iterator begin() { return _M_leftmost(); }
685
+ const_iterator begin() const { return _M_leftmost(); }
686
+ iterator end() { return _M_header; }
687
+ const_iterator end() const { return _M_header; }
688
+ reverse_iterator rbegin() { return reverse_iterator(end()); }
689
+ const_reverse_iterator rbegin() const {
690
+ return const_reverse_iterator(end());
691
+ }
692
+ reverse_iterator rend() { return reverse_iterator(begin()); }
693
+ const_reverse_iterator rend() const {
694
+ return const_reverse_iterator(begin());
695
+ }
696
+ bool empty() const { return _M_node_count == 0; }
697
+ size_type size() const { return _M_node_count; }
698
+ size_type max_size() const { return size_type(-1); }
699
+
700
+ void swap(_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __t) {
701
+ __STD::swap(_M_header, __t._M_header);
702
+ __STD::swap(_M_node_count, __t._M_node_count);
703
+ __STD::swap(_M_key_compare, __t._M_key_compare);
704
+ }
705
+
706
+ public:
707
+ // insert/erase
708
+ pair<iterator,bool> insert_unique(const value_type& __x);
709
+ iterator insert_equal(const value_type& __x);
710
+
711
+ iterator insert_unique(iterator __position, const value_type& __x);
712
+ iterator insert_equal(iterator __position, const value_type& __x);
713
+
714
+ #ifdef __STL_MEMBER_TEMPLATES
715
+ template <class _InputIterator>
716
+ void insert_unique(_InputIterator __first, _InputIterator __last);
717
+ template <class _InputIterator>
718
+ void insert_equal(_InputIterator __first, _InputIterator __last);
719
+ #else /* __STL_MEMBER_TEMPLATES */
720
+ void insert_unique(const_iterator __first, const_iterator __last);
721
+ void insert_unique(const value_type* __first, const value_type* __last);
722
+ void insert_equal(const_iterator __first, const_iterator __last);
723
+ void insert_equal(const value_type* __first, const value_type* __last);
724
+ #endif /* __STL_MEMBER_TEMPLATES */
725
+
726
+ void erase(iterator __position);
727
+ size_type erase(const key_type& __x);
728
+ void erase(iterator __first, iterator __last);
729
+ void erase(const key_type* __first, const key_type* __last);
730
+ void clear() {
731
+ if (_M_node_count != 0) {
732
+ _M_erase(_M_root());
733
+ _M_leftmost() = _M_header;
734
+ _M_root() = 0;
735
+ _M_rightmost() = _M_header;
736
+ _M_node_count = 0;
737
+ }
738
+ }
739
+
740
+ public:
741
+ // set operations:
742
+ iterator find(const key_type& __x);
743
+ const_iterator find(const key_type& __x) const;
744
+ size_type count(const key_type& __x) const;
745
+ iterator lower_bound(const key_type& __x);
746
+ const_iterator lower_bound(const key_type& __x) const;
747
+ iterator upper_bound(const key_type& __x);
748
+ const_iterator upper_bound(const key_type& __x) const;
749
+ pair<iterator,iterator> equal_range(const key_type& __x);
750
+ pair<const_iterator, const_iterator> equal_range(const key_type& __x) const;
751
+
752
+ public:
753
+ // Debugging.
754
+ bool __rb_verify() const;
755
+ };
756
+
757
+ template <class _Key, class _Value, class _KeyOfValue,
758
+ class _Compare, class _Alloc>
759
+ inline bool
760
+ operator==(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x,
761
+ const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __y)
762
+ {
763
+ return __x.size() == __y.size() &&
764
+ equal(__x.begin(), __x.end(), __y.begin());
765
+ }
766
+
767
+ template <class _Key, class _Value, class _KeyOfValue,
768
+ class _Compare, class _Alloc>
769
+ inline bool
770
+ operator<(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x,
771
+ const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __y)
772
+ {
773
+ return lexicographical_compare(__x.begin(), __x.end(),
774
+ __y.begin(), __y.end());
775
+ }
776
+
777
+ #ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER
778
+
779
+ template <class _Key, class _Value, class _KeyOfValue,
780
+ class _Compare, class _Alloc>
781
+ inline void
782
+ swap(_Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x,
783
+ _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __y)
784
+ {
785
+ __x.swap(__y);
786
+ }
787
+
788
+ #endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */
789
+
790
+
791
+ template <class _Key, class _Value, class _KeyOfValue,
792
+ class _Compare, class _Alloc>
793
+ _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>&
794
+ _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>
795
+ ::operator=(const _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>& __x)
796
+ {
797
+ if (this != &__x) {
798
+ // Note that _Key may be a constant type.
799
+ clear();
800
+ _M_node_count = 0;
801
+ _M_key_compare = __x._M_key_compare;
802
+ if (__x._M_root() == 0) {
803
+ _M_root() = 0;
804
+ _M_leftmost() = _M_header;
805
+ _M_rightmost() = _M_header;
806
+ }
807
+ else {
808
+ _M_root() = _M_copy(__x._M_root(), _M_header);
809
+ _M_leftmost() = _S_minimum(_M_root());
810
+ _M_rightmost() = _S_maximum(_M_root());
811
+ _M_node_count = __x._M_node_count;
812
+ }
813
+ }
814
+ return *this;
815
+ }
816
+
817
+ template <class _Key, class _Value, class _KeyOfValue,
818
+ class _Compare, class _Alloc>
819
+ typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::iterator
820
+ _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>
821
+ ::_M_insert(_Base_ptr __x_, _Base_ptr __y_, const _Value& __v)
822
+ {
823
+ _Link_type __x = (_Link_type) __x_;
824
+ _Link_type __y = (_Link_type) __y_;
825
+ _Link_type __z;
826
+
827
+ if (__y == _M_header || __x != 0 ||
828
+ _M_key_compare(_KeyOfValue()(__v), _S_key(__y))) {
829
+ __z = _M_create_node(__v);
830
+ _S_left(__y) = __z; // also makes _M_leftmost() = __z
831
+ // when __y == _M_header
832
+ if (__y == _M_header) {
833
+ _M_root() = __z;
834
+ _M_rightmost() = __z;
835
+ }
836
+ else if (__y == _M_leftmost())
837
+ _M_leftmost() = __z; // maintain _M_leftmost() pointing to min node
838
+ }
839
+ else {
840
+ __z = _M_create_node(__v);
841
+ _S_right(__y) = __z;
842
+ if (__y == _M_rightmost())
843
+ _M_rightmost() = __z; // maintain _M_rightmost() pointing to max node
844
+ }
845
+ _S_parent(__z) = __y;
846
+ _S_left(__z) = 0;
847
+ _S_right(__z) = 0;
848
+ _Rb_tree_rebalance(__z, _M_header->_M_parent);
849
+ ++_M_node_count;
850
+ return iterator(__z);
851
+ }
852
+
853
+ template <class _Key, class _Value, class _KeyOfValue,
854
+ class _Compare, class _Alloc>
855
+ typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::iterator
856
+ _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>
857
+ ::insert_equal(const _Value& __v)
858
+ {
859
+ _Link_type __y = _M_header;
860
+ _Link_type __x = _M_root();
861
+ while (__x != 0) {
862
+ __y = __x;
863
+ __x = _M_key_compare(_KeyOfValue()(__v), _S_key(__x)) ?
864
+ _S_left(__x) : _S_right(__x);
865
+ }
866
+ return _M_insert(__x, __y, __v);
867
+ }
868
+
869
+
870
+ template <class _Key, class _Value, class _KeyOfValue,
871
+ class _Compare, class _Alloc>
872
+ pair<typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::iterator,
873
+ bool>
874
+ _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>
875
+ ::insert_unique(const _Value& __v)
876
+ {
877
+ _Link_type __y = _M_header;
878
+ _Link_type __x = _M_root();
879
+ bool __comp = true;
880
+ while (__x != 0) {
881
+ __y = __x;
882
+ __comp = _M_key_compare(_KeyOfValue()(__v), _S_key(__x));
883
+ __x = __comp ? _S_left(__x) : _S_right(__x);
884
+ }
885
+ iterator __j = iterator(__y);
886
+ if (__comp)
887
+ if (__j == begin())
888
+ return pair<iterator,bool>(_M_insert(__x, __y, __v), true);
889
+ else
890
+ --__j;
891
+ if (_M_key_compare(_S_key(__j._M_node), _KeyOfValue()(__v)))
892
+ return pair<iterator,bool>(_M_insert(__x, __y, __v), true);
893
+ return pair<iterator,bool>(__j, false);
894
+ }
895
+
896
+
897
+ template <class _Key, class _Val, class _KeyOfValue,
898
+ class _Compare, class _Alloc>
899
+ typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
900
+ _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>
901
+ ::insert_unique(iterator __position, const _Val& __v)
902
+ {
903
+ if (__position._M_node == _M_header->_M_left) { // begin()
904
+ if (size() > 0 &&
905
+ _M_key_compare(_KeyOfValue()(__v), _S_key(__position._M_node)))
906
+ return _M_insert(__position._M_node, __position._M_node, __v);
907
+ // first argument just needs to be non-null
908
+ else
909
+ return insert_unique(__v).first;
910
+ } else if (__position._M_node == _M_header) { // end()
911
+ if (_M_key_compare(_S_key(_M_rightmost()), _KeyOfValue()(__v)))
912
+ return _M_insert(0, _M_rightmost(), __v);
913
+ else
914
+ return insert_unique(__v).first;
915
+ } else {
916
+ iterator __before = __position;
917
+ --__before;
918
+ if (_M_key_compare(_S_key(__before._M_node), _KeyOfValue()(__v))
919
+ && _M_key_compare(_KeyOfValue()(__v), _S_key(__position._M_node))) {
920
+ if (_S_right(__before._M_node) == 0)
921
+ return _M_insert(0, __before._M_node, __v);
922
+ else
923
+ return _M_insert(__position._M_node, __position._M_node, __v);
924
+ // first argument just needs to be non-null
925
+ } else
926
+ return insert_unique(__v).first;
927
+ }
928
+ }
929
+
930
+ template <class _Key, class _Val, class _KeyOfValue,
931
+ class _Compare, class _Alloc>
932
+ typename _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::iterator
933
+ _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>
934
+ ::insert_equal(iterator __position, const _Val& __v)
935
+ {
936
+ if (__position._M_node == _M_header->_M_left) { // begin()
937
+ if (size() > 0 &&
938
+ _M_key_compare(_KeyOfValue()(__v), _S_key(__position._M_node)))
939
+ return _M_insert(__position._M_node, __position._M_node, __v);
940
+ // first argument just needs to be non-null
941
+ else
942
+ return insert_equal(__v);
943
+ } else if (__position._M_node == _M_header) {// end()
944
+ if (!_M_key_compare(_KeyOfValue()(__v), _S_key(_M_rightmost())))
945
+ return _M_insert(0, _M_rightmost(), __v);
946
+ else
947
+ return insert_equal(__v);
948
+ } else {
949
+ iterator __before = __position;
950
+ --__before;
951
+ if (!_M_key_compare(_KeyOfValue()(__v), _S_key(__before._M_node))
952
+ && !_M_key_compare(_S_key(__position._M_node), _KeyOfValue()(__v))) {
953
+ if (_S_right(__before._M_node) == 0)
954
+ return _M_insert(0, __before._M_node, __v);
955
+ else
956
+ return _M_insert(__position._M_node, __position._M_node, __v);
957
+ // first argument just needs to be non-null
958
+ } else
959
+ return insert_equal(__v);
960
+ }
961
+ }
962
+
963
+ #ifdef __STL_MEMBER_TEMPLATES
964
+
965
+ template <class _Key, class _Val, class _KoV, class _Cmp, class _Alloc>
966
+ template<class _II>
967
+ void _Rb_tree<_Key,_Val,_KoV,_Cmp,_Alloc>
968
+ ::insert_equal(_II __first, _II __last)
969
+ {
970
+ for ( ; __first != __last; ++__first)
971
+ insert_equal(*__first);
972
+ }
973
+
974
+ template <class _Key, class _Val, class _KoV, class _Cmp, class _Alloc>
975
+ template<class _II>
976
+ void _Rb_tree<_Key,_Val,_KoV,_Cmp,_Alloc>
977
+ ::insert_unique(_II __first, _II __last) {
978
+ for ( ; __first != __last; ++__first)
979
+ insert_unique(*__first);
980
+ }
981
+
982
+ #else /* __STL_MEMBER_TEMPLATES */
983
+
984
+ template <class _Key, class _Val, class _KoV, class _Cmp, class _Alloc>
985
+ void
986
+ _Rb_tree<_Key,_Val,_KoV,_Cmp,_Alloc>
987
+ ::insert_equal(const _Val* __first, const _Val* __last)
988
+ {
989
+ for ( ; __first != __last; ++__first)
990
+ insert_equal(*__first);
991
+ }
992
+
993
+ template <class _Key, class _Val, class _KoV, class _Cmp, class _Alloc>
994
+ void
995
+ _Rb_tree<_Key,_Val,_KoV,_Cmp,_Alloc>
996
+ ::insert_equal(const_iterator __first, const_iterator __last)
997
+ {
998
+ for ( ; __first != __last; ++__first)
999
+ insert_equal(*__first);
1000
+ }
1001
+
1002
+ template <class _Key, class _Val, class _KoV, class _Cmp, class _Alloc>
1003
+ void
1004
+ _Rb_tree<_Key,_Val,_KoV,_Cmp,_Alloc>
1005
+ ::insert_unique(const _Val* __first, const _Val* __last)
1006
+ {
1007
+ for ( ; __first != __last; ++__first)
1008
+ insert_unique(*__first);
1009
+ }
1010
+
1011
+ template <class _Key, class _Val, class _KoV, class _Cmp, class _Alloc>
1012
+ void _Rb_tree<_Key,_Val,_KoV,_Cmp,_Alloc>
1013
+ ::insert_unique(const_iterator __first, const_iterator __last)
1014
+ {
1015
+ for ( ; __first != __last; ++__first)
1016
+ insert_unique(*__first);
1017
+ }
1018
+
1019
+ #endif /* __STL_MEMBER_TEMPLATES */
1020
+
1021
+ template <class _Key, class _Value, class _KeyOfValue,
1022
+ class _Compare, class _Alloc>
1023
+ inline void _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>
1024
+ ::erase(iterator __position)
1025
+ {
1026
+ _Link_type __y =
1027
+ (_Link_type) _Rb_tree_rebalance_for_erase(__position._M_node,
1028
+ _M_header->_M_parent,
1029
+ _M_header->_M_left,
1030
+ _M_header->_M_right);
1031
+ destroy_node(__y);
1032
+ --_M_node_count;
1033
+ }
1034
+
1035
+ template <class _Key, class _Value, class _KeyOfValue,
1036
+ class _Compare, class _Alloc>
1037
+ typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::size_type
1038
+ _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::erase(const _Key& __x)
1039
+ {
1040
+ pair<iterator,iterator> __p = equal_range(__x);
1041
+ size_type __n = 0;
1042
+ distance(__p.first, __p.second, __n);
1043
+ erase(__p.first, __p.second);
1044
+ return __n;
1045
+ }
1046
+
1047
+ template <class _Key, class _Val, class _KoV, class _Compare, class _Alloc>
1048
+ typename _Rb_tree<_Key, _Val, _KoV, _Compare, _Alloc>::_Link_type
1049
+ _Rb_tree<_Key,_Val,_KoV,_Compare,_Alloc>
1050
+ ::_M_copy(_Link_type __x, _Link_type __p)
1051
+ {
1052
+ // structural copy. __x and __p must be non-null.
1053
+ _Link_type __top = _M_clone_node(__x);
1054
+ __top->_M_parent = __p;
1055
+
1056
+ __STL_TRY {
1057
+ if (__x->_M_right)
1058
+ __top->_M_right = _M_copy(_S_right(__x), __top);
1059
+ __p = __top;
1060
+ __x = _S_left(__x);
1061
+
1062
+ while (__x != 0) {
1063
+ _Link_type __y = _M_clone_node(__x);
1064
+ __p->_M_left = __y;
1065
+ __y->_M_parent = __p;
1066
+ if (__x->_M_right)
1067
+ __y->_M_right = _M_copy(_S_right(__x), __y);
1068
+ __p = __y;
1069
+ __x = _S_left(__x);
1070
+ }
1071
+ }
1072
+ __STL_UNWIND(_M_erase(__top));
1073
+
1074
+ return __top;
1075
+ }
1076
+
1077
+ template <class _Key, class _Value, class _KeyOfValue,
1078
+ class _Compare, class _Alloc>
1079
+ void _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>
1080
+ ::_M_erase(_Link_type __x)
1081
+ {
1082
+ // erase without rebalancing
1083
+ while (__x != 0) {
1084
+ _M_erase(_S_right(__x));
1085
+ _Link_type __y = _S_left(__x);
1086
+ destroy_node(__x);
1087
+ __x = __y;
1088
+ }
1089
+ }
1090
+
1091
+ template <class _Key, class _Value, class _KeyOfValue,
1092
+ class _Compare, class _Alloc>
1093
+ void _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>
1094
+ ::erase(iterator __first, iterator __last)
1095
+ {
1096
+ if (__first == begin() && __last == end())
1097
+ clear();
1098
+ else
1099
+ while (__first != __last) erase(__first++);
1100
+ }
1101
+
1102
+ template <class _Key, class _Value, class _KeyOfValue,
1103
+ class _Compare, class _Alloc>
1104
+ void _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>
1105
+ ::erase(const _Key* __first, const _Key* __last)
1106
+ {
1107
+ while (__first != __last) erase(*__first++);
1108
+ }
1109
+
1110
+ template <class _Key, class _Value, class _KeyOfValue,
1111
+ class _Compare, class _Alloc>
1112
+ typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::iterator
1113
+ _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::find(const _Key& __k)
1114
+ {
1115
+ _Link_type __y = _M_header; // Last node which is not less than __k.
1116
+ _Link_type __x = _M_root(); // Current node.
1117
+
1118
+ while (__x != 0)
1119
+ if (!_M_key_compare(_S_key(__x), __k))
1120
+ __y = __x, __x = _S_left(__x);
1121
+ else
1122
+ __x = _S_right(__x);
1123
+
1124
+ iterator __j = iterator(__y);
1125
+ return (__j == end() || _M_key_compare(__k, _S_key(__j._M_node))) ?
1126
+ end() : __j;
1127
+ }
1128
+
1129
+ template <class _Key, class _Value, class _KeyOfValue,
1130
+ class _Compare, class _Alloc>
1131
+ typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::const_iterator
1132
+ _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::find(const _Key& __k) const
1133
+ {
1134
+ _Link_type __y = _M_header; /* Last node which is not less than __k. */
1135
+ _Link_type __x = _M_root(); /* Current node. */
1136
+
1137
+ while (__x != 0) {
1138
+ if (!_M_key_compare(_S_key(__x), __k))
1139
+ __y = __x, __x = _S_left(__x);
1140
+ else
1141
+ __x = _S_right(__x);
1142
+ }
1143
+ const_iterator __j = const_iterator(__y);
1144
+ return (__j == end() || _M_key_compare(__k, _S_key(__j._M_node))) ?
1145
+ end() : __j;
1146
+ }
1147
+
1148
+ template <class _Key, class _Value, class _KeyOfValue,
1149
+ class _Compare, class _Alloc>
1150
+ typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::size_type
1151
+ _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>
1152
+ ::count(const _Key& __k) const
1153
+ {
1154
+ pair<const_iterator, const_iterator> __p = equal_range(__k);
1155
+ size_type __n = 0;
1156
+ distance(__p.first, __p.second, __n);
1157
+ return __n;
1158
+ }
1159
+
1160
+ template <class _Key, class _Value, class _KeyOfValue,
1161
+ class _Compare, class _Alloc>
1162
+ typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::iterator
1163
+ _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>
1164
+ ::lower_bound(const _Key& __k)
1165
+ {
1166
+ _Link_type __y = _M_header; /* Last node which is not less than __k. */
1167
+ _Link_type __x = _M_root(); /* Current node. */
1168
+
1169
+ while (__x != 0)
1170
+ if (!_M_key_compare(_S_key(__x), __k))
1171
+ __y = __x, __x = _S_left(__x);
1172
+ else
1173
+ __x = _S_right(__x);
1174
+
1175
+ return iterator(__y);
1176
+ }
1177
+
1178
+ template <class _Key, class _Value, class _KeyOfValue,
1179
+ class _Compare, class _Alloc>
1180
+ typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::const_iterator
1181
+ _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>
1182
+ ::lower_bound(const _Key& __k) const
1183
+ {
1184
+ _Link_type __y = _M_header; /* Last node which is not less than __k. */
1185
+ _Link_type __x = _M_root(); /* Current node. */
1186
+
1187
+ while (__x != 0)
1188
+ if (!_M_key_compare(_S_key(__x), __k))
1189
+ __y = __x, __x = _S_left(__x);
1190
+ else
1191
+ __x = _S_right(__x);
1192
+
1193
+ return const_iterator(__y);
1194
+ }
1195
+
1196
+ template <class _Key, class _Value, class _KeyOfValue,
1197
+ class _Compare, class _Alloc>
1198
+ typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::iterator
1199
+ _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>
1200
+ ::upper_bound(const _Key& __k)
1201
+ {
1202
+ _Link_type __y = _M_header; /* Last node which is greater than __k. */
1203
+ _Link_type __x = _M_root(); /* Current node. */
1204
+
1205
+ while (__x != 0)
1206
+ if (_M_key_compare(__k, _S_key(__x)))
1207
+ __y = __x, __x = _S_left(__x);
1208
+ else
1209
+ __x = _S_right(__x);
1210
+
1211
+ return iterator(__y);
1212
+ }
1213
+
1214
+ template <class _Key, class _Value, class _KeyOfValue,
1215
+ class _Compare, class _Alloc>
1216
+ typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::const_iterator
1217
+ _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>
1218
+ ::upper_bound(const _Key& __k) const
1219
+ {
1220
+ _Link_type __y = _M_header; /* Last node which is greater than __k. */
1221
+ _Link_type __x = _M_root(); /* Current node. */
1222
+
1223
+ while (__x != 0)
1224
+ if (_M_key_compare(__k, _S_key(__x)))
1225
+ __y = __x, __x = _S_left(__x);
1226
+ else
1227
+ __x = _S_right(__x);
1228
+
1229
+ return const_iterator(__y);
1230
+ }
1231
+
1232
+ template <class _Key, class _Value, class _KeyOfValue,
1233
+ class _Compare, class _Alloc>
1234
+ inline
1235
+ pair<typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::iterator,
1236
+ typename _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::iterator>
1237
+ _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>
1238
+ ::equal_range(const _Key& __k)
1239
+ {
1240
+ return pair<iterator, iterator>(lower_bound(__k), upper_bound(__k));
1241
+ }
1242
+
1243
+ template <class _Key, class _Value, class _KoV, class _Compare, class _Alloc>
1244
+ inline
1245
+ pair<typename _Rb_tree<_Key, _Value, _KoV, _Compare, _Alloc>::const_iterator,
1246
+ typename _Rb_tree<_Key, _Value, _KoV, _Compare, _Alloc>::const_iterator>
1247
+ _Rb_tree<_Key, _Value, _KoV, _Compare, _Alloc>
1248
+ ::equal_range(const _Key& __k) const
1249
+ {
1250
+ return pair<const_iterator,const_iterator>(lower_bound(__k),
1251
+ upper_bound(__k));
1252
+ }
1253
+
1254
+ inline int
1255
+ __black_count(_Rb_tree_node_base* __node, _Rb_tree_node_base* __root)
1256
+ {
1257
+ if (__node == 0)
1258
+ return 0;
1259
+ else {
1260
+ int __bc = __node->_M_color == _S_rb_tree_black ? 1 : 0;
1261
+ if (__node == __root)
1262
+ return __bc;
1263
+ else
1264
+ return __bc + __black_count(__node->_M_parent, __root);
1265
+ }
1266
+ }
1267
+
1268
+ template <class _Key, class _Value, class _KeyOfValue,
1269
+ class _Compare, class _Alloc>
1270
+ bool _Rb_tree<_Key,_Value,_KeyOfValue,_Compare,_Alloc>::__rb_verify() const
1271
+ {
1272
+ if (_M_node_count == 0 || begin() == end())
1273
+ return _M_node_count == 0 && begin() == end() &&
1274
+ _M_header->_M_left == _M_header && _M_header->_M_right == _M_header;
1275
+
1276
+ int __len = __black_count(_M_leftmost(), _M_root());
1277
+ for (const_iterator __it = begin(); __it != end(); ++__it) {
1278
+ _Link_type __x = (_Link_type) __it._M_node;
1279
+ _Link_type __L = _S_left(__x);
1280
+ _Link_type __R = _S_right(__x);
1281
+
1282
+ if (__x->_M_color == _S_rb_tree_red)
1283
+ if ((__L && __L->_M_color == _S_rb_tree_red) ||
1284
+ (__R && __R->_M_color == _S_rb_tree_red))
1285
+ return false;
1286
+
1287
+ if (__L && _M_key_compare(_S_key(__x), _S_key(__L)))
1288
+ return false;
1289
+ if (__R && _M_key_compare(_S_key(__R), _S_key(__x)))
1290
+ return false;
1291
+
1292
+ if (!__L && !__R && __black_count(__x, _M_root()) != __len)
1293
+ return false;
1294
+ }
1295
+
1296
+ if (_M_leftmost() != _Rb_tree_node_base::_S_minimum(_M_root()))
1297
+ return false;
1298
+ if (_M_rightmost() != _Rb_tree_node_base::_S_maximum(_M_root()))
1299
+ return false;
1300
+
1301
+ return true;
1302
+ }
1303
+
1304
+ // Class rb_tree is not part of the C++ standard. It is provided for
1305
+ // compatibility with the HP STL.
1306
+
1307
+ template <class _Key, class _Value, class _KeyOfValue, class _Compare,
1308
+ class _Alloc = __STL_DEFAULT_ALLOCATOR(_Value) >
1309
+ struct rb_tree : public _Rb_tree<_Key, _Value, _KeyOfValue, _Compare, _Alloc>
1310
+ {
1311
+ typedef _Rb_tree<_Key, _Value, _KeyOfValue, _Compare, _Alloc> _Base;
1312
+ typedef typename _Base::allocator_type allocator_type;
1313
+
1314
+ rb_tree(const _Compare& __comp = _Compare(),
1315
+ const allocator_type& __a = allocator_type())
1316
+ : _Base(__comp, __a) {}
1317
+
1318
+ ~rb_tree() {}
1319
+ };
1320
+
1321
+ #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
1322
+ #pragma reset woff 1375
1323
+ #endif
1324
+
1325
+ __STL_END_NAMESPACE
1326
+
1327
+ #endif /* __SGI_STL_INTERNAL_TREE_H */
1328
+
1329
+ // Local Variables:
1330
+ // mode:C++
1331
+ // End: