@@ 341-371 (lines=31) @@ | ||
338 | * |
|
339 | * @since 1.0.0 |
|
340 | */ |
|
341 | private function _rotateLeft() |
|
342 | { |
|
343 | $right = $this->right; |
|
344 | ||
345 | if ($right->information & 2) |
|
346 | { |
|
347 | $this->right = $right->left; |
|
348 | $right->left = $this; |
|
349 | } |
|
350 | else |
|
351 | { |
|
352 | $right->information |= 2; |
|
353 | $this->information &= ~ 1; |
|
354 | } |
|
355 | ||
356 | $this->information -= 4; |
|
357 | ||
358 | if ($right->information >= 4) |
|
359 | { |
|
360 | $this->information -= $right->information & ~3; |
|
361 | } |
|
362 | ||
363 | $right->information -= 4; |
|
364 | ||
365 | if ($this->information < 0) |
|
366 | { |
|
367 | $right->information += $this->information & ~3; |
|
368 | } |
|
369 | ||
370 | return $right; |
|
371 | } |
|
372 | ||
373 | /** |
|
374 | * Rotate the node to the right |
|
@@ 380-410 (lines=31) @@ | ||
377 | * |
|
378 | * @since 1.0.0 |
|
379 | */ |
|
380 | private function _rotateRight() |
|
381 | { |
|
382 | $left = $this->left; |
|
383 | ||
384 | if ($left->information & 1) |
|
385 | { |
|
386 | $this->left = $left->right; |
|
387 | $left->right = $this; |
|
388 | } |
|
389 | else |
|
390 | { |
|
391 | $this->information &= ~ 2; |
|
392 | $left->information |= 1; |
|
393 | } |
|
394 | ||
395 | $this->information += 4; |
|
396 | ||
397 | if ($left->information < 0) |
|
398 | { |
|
399 | $this->information -= $left->information & ~3; |
|
400 | } |
|
401 | ||
402 | $left->information += 4; |
|
403 | ||
404 | if ($this->information >= 4) |
|
405 | { |
|
406 | $left->information += $this->information & ~3; |
|
407 | } |
|
408 | ||
409 | return $left; |
|
410 | } |
|
411 | ||
412 | /** |
|
413 | * Increment the balance of the node |