Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. TimerQueue.php

function TimerQueue::heapifyDown

Parameters

int $node Rebuild the data array from the given node downward.:

1 call to TimerQueue::heapifyDown()
TimerQueue::removeAndRebuild in vendor/revolt/event-loop/src/EventLoop/Internal/TimerQueue.php

File

vendor/revolt/event-loop/src/EventLoop/Internal/TimerQueue.php, line 104

Class

TimerQueue
Uses a binary tree stored in an array to implement a heap.

Namespace

Revolt\EventLoop\Internal

Code

private function heapifyDown(int $node) : void {
    $length = \count($this->callbacks);
    while (($child = ($node << 1) + 1) < $length) {
        if ($this->callbacks[$child]->expiration < $this->callbacks[$node]->expiration && ($child + 1 >= $length || $this->callbacks[$child]->expiration < $this->callbacks[$child + 1]->expiration)) {
            // Left child is less than parent and right child.
            $swap = $child;
        }
        elseif ($child + 1 < $length && $this->callbacks[$child + 1]->expiration < $this->callbacks[$node]->expiration) {
            // Right child is less than parent and left child.
            $swap = $child + 1;
        }
        else {
            // Left and right child are greater than parent.
            break;
        }
        $this->swap($node, $swap);
        $node = $swap;
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal