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