(Node<K, V> x)
| 5119 | } |
| 5120 | |
| 5121 | private void fixup(Node<K, V> x) { |
| 5122 | Node<K, V> w; |
| 5123 | while (x != root && !x.color) { |
| 5124 | if (x == x.parent.left) { |
| 5125 | w = x.parent.right; |
| 5126 | if (w == null) { |
| 5127 | x = x.parent; |
| 5128 | continue; |
| 5129 | } |
| 5130 | if (w.color) { |
| 5131 | w.color = false; |
| 5132 | x.parent.color = true; |
| 5133 | leftRotate(x.parent); |
| 5134 | w = x.parent.right; |
| 5135 | if (w == null) { |
| 5136 | x = x.parent; |
| 5137 | continue; |
| 5138 | } |
| 5139 | } |
| 5140 | if ((w.left == null || !w.left.color) |
| 5141 | && (w.right == null || !w.right.color)) { |
| 5142 | w.color = true; |
| 5143 | x = x.parent; |
| 5144 | } else { |
| 5145 | if (w.right == null || !w.right.color) { |
| 5146 | w.left.color = false; |
| 5147 | w.color = true; |
| 5148 | rightRotate(w); |
| 5149 | w = x.parent.right; |
| 5150 | } |
| 5151 | w.color = x.parent.color; |
| 5152 | x.parent.color = false; |
| 5153 | w.right.color = false; |
| 5154 | leftRotate(x.parent); |
| 5155 | x = root; |
| 5156 | } |
| 5157 | } else { |
| 5158 | w = x.parent.left; |
| 5159 | if (w == null) { |
| 5160 | x = x.parent; |
| 5161 | continue; |
| 5162 | } |
| 5163 | if (w.color) { |
| 5164 | w.color = false; |
| 5165 | x.parent.color = true; |
| 5166 | rightRotate(x.parent); |
| 5167 | w = x.parent.left; |
| 5168 | if (w == null) { |
| 5169 | x = x.parent; |
| 5170 | continue; |
| 5171 | } |
| 5172 | } |
| 5173 | if ((w.left == null || !w.left.color) |
| 5174 | && (w.right == null || !w.right.color)) { |
| 5175 | w.color = true; |
| 5176 | x = x.parent; |
| 5177 | } else { |
| 5178 | if (w.left == null || !w.left.color) { |
no test coverage detected