MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / fixup

Method fixup

Ports/CLDC11/src/java/util/TreeMap.java:5152–5224  ·  view source on GitHub ↗
(Node<K, V> x)

Source from the content-addressed store, hash-verified

5150 }
5151
5152 private void fixup(Node<K, V> x) {
5153 Node<K, V> w;
5154 while (x != root && !x.color) {
5155 if (x == x.parent.left) {
5156 w = x.parent.right;
5157 if (w == null) {
5158 x = x.parent;
5159 continue;
5160 }
5161 if (w.color) {
5162 w.color = false;
5163 x.parent.color = true;
5164 leftRotate(x.parent);
5165 w = x.parent.right;
5166 if (w == null) {
5167 x = x.parent;
5168 continue;
5169 }
5170 }
5171 if ((w.left == null || !w.left.color)
5172 && (w.right == null || !w.right.color)) {
5173 w.color = true;
5174 x = x.parent;
5175 } else {
5176 if (w.right == null || !w.right.color) {
5177 w.left.color = false;
5178 w.color = true;
5179 rightRotate(w);
5180 w = x.parent.right;
5181 }
5182 w.color = x.parent.color;
5183 x.parent.color = false;
5184 w.right.color = false;
5185 leftRotate(x.parent);
5186 x = root;
5187 }
5188 } else {
5189 w = x.parent.left;
5190 if (w == null) {
5191 x = x.parent;
5192 continue;
5193 }
5194 if (w.color) {
5195 w.color = false;
5196 x.parent.color = true;
5197 rightRotate(x.parent);
5198 w = x.parent.left;
5199 if (w == null) {
5200 x = x.parent;
5201 continue;
5202 }
5203 }
5204 if ((w.left == null || !w.left.color)
5205 && (w.right == null || !w.right.color)) {
5206 w.color = true;
5207 x = x.parent;
5208 } else {
5209 if (w.left == null || !w.left.color) {

Callers 2

attachToParentMethod · 0.95
attachNullToParentMethod · 0.95

Calls 2

leftRotateMethod · 0.95
rightRotateMethod · 0.95

Tested by

no test coverage detected