Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<SplMinHeap::compareSplPriorityQueue::compare>
^DatastructuresLast updated: Mon, 26 Oct 2026

The SplPriorityQueue class

(PHP 5 >= 5.3.0, PHP 7, PHP 8)

Introduction

The SplPriorityQueue class provides the main functionalities of a prioritized queue, implemented using a max heap.

Note:

The order of elements with identical priority is undefined. It may differ from the order in which they have been inserted.

Class synopsis

class SplPriorityQueue implements Iterator, Countable {
/* Constants */
public const int EXTR_BOTH;
public const int EXTR_PRIORITY;
public const int EXTR_DATA;
/* Methods */
public function compare(mixed $priority1, mixed $priority2): int
public function count(): int
public function current(): mixed
public function extract(): mixed
public function getExtractFlags(): int
public function insert(mixed $value, mixed $priority): true
public function isCorrupted(): bool
public function isEmpty(): bool
public function key(): int
public function next(): void
public function recoverFromCorruption(): true
public function rewind(): void
public function setExtractFlags(int $flags): int
public function top(): mixed
public function valid(): bool
}

Changelog

Version Description
8.4.0 The class constants are now typed.

Table of Contents


<SplMinHeap::compareSplPriorityQueue::compare>
^DatastructuresLast updated: Mon, 26 Oct 2026