Heap::extractInsert

(Available since version 1.0)

Heap::extractInsertExtracts a node from top of the heap and inserts a new one

Description

public mixed Heap::extractInsert ( mixed $value )

Extracts a node from top of the heap, inserts value and sifts up. Runs in Θ(log(n)) amortized time, where n is the size of the heap. Faster than extracting and inserting separately.

Parameters

value

The value to insert.

Return Values

The value of the extracted node.

Errors/Exceptions

Throws SEIDS::Heaps::ExtractException when the data-structure is empty.

To Top