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
 
<SplHeap::validSplMaxHeap::compare>
^DatastructuresLast updated: Mon, 26 Oct 2026

The SplMaxHeap class

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

Introduction

The SplMaxHeap class provides the main functionalities of a heap, keeping the maximum on the top.

Class synopsis

class SplMaxHeap extends SplHeap {
/* Methods */
protected function compare(mixed $value1, mixed $value2): int
/* Inherited methods */
protected function SplHeap::compare(mixed $value1, mixed $value2): int
public function SplHeap::count(): int
public function SplHeap::current(): mixed
public function SplHeap::extract(): mixed
public function SplHeap::insert(mixed $value): true
public function SplHeap::isCorrupted(): bool
public function SplHeap::isEmpty(): bool
public function SplHeap::key(): int
public function SplHeap::next(): void
public function SplHeap::rewind(): void
public function SplHeap::top(): mixed
public function SplHeap::valid(): bool
}

Table of Contents

  • SplMaxHeap::compare — Compare elements in order to place them correctly in the heap while sifting up

<SplHeap::validSplMaxHeap::compare>
^DatastructuresLast updated: Mon, 26 Oct 2026