PHP code example of justblackbird / stable-priority-queue

1. Go to this page and download the library: Download justblackbird/stable-priority-queue library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

justblackbird / stable-priority-queue example snippets


$q = new \SplPriorityQueue();

$q->insert(1, 0);
$q->insert(2, 0);
$q->insert(3, 0);
$q->insert(4, 0);

while (!$q->isEmpty()) {
    echo $q->extract() . " ";
}


use JustBlackBird\StablePriorityQueue\Queue;

$q = new Queue();

$q->insert(1, 0);
$q->insert(2, 0);
$q->insert(3, 0);
$q->insert(4, 0);

while (!$q->isEmpty()) {
    echo $q->extract() . " ";
}

// "1 2 3 4" will be outputted.