PHP
SPL

SplHeap (class)

The SplHeap class

Introduction

(PHP 5 >= 5.3.0, PHP 7)

The SplHeap class provides the main functionalities of a Heap.

Class synopsis

abstract SplHeap implements Iterator , Countable {

/* Methods */

public __construct ( void )

abstract protected int compare ( mixed $value1 , mixed $value2 )

public int count ( void )

public mixed current ( void )

public mixed extract ( void )

public void insert ( mixed $value )

public bool isEmpty ( void )

public mixed key ( void )

public void next ( void )

public void recoverFromCorruption ( void )

public void rewind ( void )

public mixed top ( void )

public bool valid ( void )

}

Table of Contents

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

  • SplHeap::__construct — Constructs a new empty heap

  • SplHeap::count — Counts the number of elements in the heap.

  • SplHeap::current — Return current node pointed by the iterator

  • SplHeap::extract — Extracts a node from top of the heap and sift up.

  • SplHeap::insert — Inserts an element in the heap by sifting it up.

  • SplHeap::isEmpty — Checks whether the heap is empty.

  • SplHeap::key — Return current node index

  • SplHeap::recoverFromCorruption — Recover from the corrupted state and allow further actions on the heap.

  • SplHeap::rewind — Rewind iterator back to the start (no-op)

  • SplHeap::valid — Check whether the heap contains more nodes

← SplQueue::setIteratorMode

SplHeap::compare →

© 1997–2017 The PHP Documentation Group

Licensed under the Creative Commons Attribution License v3.0 or later.

https://secure.php.net/manual/en/class.splheap.php