2017 © Pedro Peláez
 

library priorityqueue

Ascending/descending PriorityQueues. Order maintained for nodes with equal priority on dequeue

image

thomaslarsson/priorityqueue

Ascending/descending PriorityQueues. Order maintained for nodes with equal priority on dequeue

  • Wednesday, February 12, 2014
  • by ThomasLarsson
  • Repository
  • 1 Watchers
  • 0 Stars
  • 57 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 24 % Grown

The README.md

PriorityQueue Build Status

Ascending/descending PriorityQueues. Order maintained for nodes with equal priority on dequeue., (*1)

Install

You can install the package using Composer., (*2)

  1. Install composer.
  2. Add the following dependency to a composer.json and:
{
    "require": {
        "thomaslarsson/priorityqueue": "1.0.*"
    }
}

The package is now installed in your vendor directory., (*3)

Usage

// Require composer's autoload
require 'vendor/autoload.php';

// Optional: Alias/import the package's namespace
use ThomasLarsson\PriorityQueue\MinPriorityQueue as MinPriorityQueue,
    ThomasLarsson\PriorityQueue\MaxPriorityQueue as MaxPriorityQueue;

// Create a ascending queue (Use the package's namespace unless you aliased it)
$ascendingQueue = new MinPriorityQueue();

// ... OR a descending queue.
$descendingQueue = new MaxPriorityQueue(); // A decending queue

// Create some data sorted descending (Just to illustrate that it's working)
$ascendingQueue->insert(4, 0);
$ascendingQueue->insert(3, 0);
$ascendingQueue->insert(2, 0);
$ascendingQueue->insert(1, 0);
$ascendingQueue->insert(0, 0);

// Display the sorted result
foreach ( $ascendingQueue as $value )
{
    echo $value . "\n";
}

Fixes equal priority sorting bug

ThomasLarsson/PriorityQueue is built on top of SplPriorityQueue. This implementation fixes problems when two or more nodes share a similar priority. The standard SPL-implementation will dequeue equal priority nodes in no particular (random) order, as noted in the manual., (*4)

SPLPriorityQueue::compare()

Note: Multiple elements with the same priority will get dequeued in no particular order., (*5)

The Versions

12/02 2014

dev-master

9999999-dev http://github.com/ThomasLarsson/PriorityQueue

Ascending/descending PriorityQueues. Order maintained for nodes with equal priority on dequeue

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Thomas Maurstad Larsson

priorityqueue ascending priorityqueue descending priorityqueue order maintained for nodes with equal priority on dequeue

02/10 2013

v1.0.0

1.0.0.0 http://github.com/ThomasLarsson/PriorityQueue

Ascending/descending PriorityQueues. Order maintained for nodes with equal priority on dequeue

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by Thomas Maurstad Larsson

priorityqueue ascending priorityqueue descending priorityqueue order maintained for nodes with equal priority on dequeue