PHPackages                             justblackbird/stable-priority-queue - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. justblackbird/stable-priority-queue

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

justblackbird/stable-priority-queue
===================================

Stable implementation of priority queue

0.1.0(5y ago)3211MITPHPPHP ^7.4

Since Aug 22Pushed 5y ago1 watchersCompare

[ Source](https://github.com/JustBlackBird/stable-priority-queue)[ Packagist](https://packagist.org/packages/justblackbird/stable-priority-queue)[ RSS](/packages/justblackbird-stable-priority-queue/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (3)Versions (2)Used By (1)

Stable Priority Queue
=====================

[](#stable-priority-queue)

[![Latest Stable Version](https://camo.githubusercontent.com/938f85c75d0ea6da6ee3796f2d3aead09131cd3f30be8da74a0225e3caab2d89/68747470733a2f2f706f7365722e707567782e6f72672f6a757374626c61636b626972642f737461626c652d7072696f726974792d71756575652f76)](//packagist.org/packages/justblackbird/stable-priority-queue) [![Test](https://github.com/JustBlackBird/stable-priority-queue/workflows/Test/badge.svg)](https://github.com/JustBlackBird/stable-priority-queue/workflows/Test/badge.svg)

> Stable implementation of priority queue data structure in PHP.

Why
---

[](#why)

There is an implementation of priority queue in SPL: `SplPriorityQueue`. The problem is it is unstable. Take a look at the example below:

```
$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() . " ";
}
```

This example retrieves a string `"1 4 3 2"` and not `"1 2 3 4"`. This library provides an implementation that extracts values of the same priorites in the order they came in. The example above will return `"1 2 3 4"`!

Installation
------------

[](#installation)

```
composer require justblackbird/stable-priority-queue

```

Usage
-----

[](#usage)

```
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.
```

License
-------

[](#license)

[MIT](http://opensource.org/licenses/MIT) (c) Dmitry Simushev

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2094d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a2b12a708d5649504df9322541ff13341f5968995c7ea2f8f83a1d19692edf26?d=identicon)[justblackbird](/maintainers/justblackbird)

---

Top Contributors

[![JustBlackBird](https://avatars.githubusercontent.com/u/1167086?v=4)](https://github.com/JustBlackBird "JustBlackBird (5 commits)")

---

Tags

data-structurephp

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/justblackbird-stable-priority-queue/health.svg)

```
[![Health](https://phpackages.com/badges/justblackbird-stable-priority-queue/health.svg)](https://phpackages.com/packages/justblackbird-stable-priority-queue)
```

###  Alternatives

[label84/laravel-hours-helper

Creates a Collection of times with a given interval.

27591.2k](/packages/label84-laravel-hours-helper)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
