abstract class SplHeap implements Iterator, Countable (View source)

Methods

TValue
extract()

Extracts a node from top of the heap and sift up.

bool
insert(TValue $value)

Inserts an element in the heap by sifting it up.

TValue
top()

Peeks at the node from the top of the heap

int<0, max>
count()

Counts the number of elements in the heap.

bool
isEmpty()

Checks whether the heap is empty.

void
rewind()

Rewind iterator back to the start (no-op)

TValue
current()

Return current node pointed by the iterator

TKey|null
key()

Return current node index

void
next()

Move to the next node

bool
valid()

Check whether the heap contains more nodes

bool
recoverFromCorruption()

Recover from the corrupted state and allow further actions on the heap.

int
compare(mixed $value1, mixed $value2)

Compare elements in order to place them correctly in the heap while sifting up.

bool
isCorrupted()

No description

array
__debugInfo()

No description

array
__serialize()

No description

__unserialize(array $data)

No description

Details

TValue extract()

Extracts a node from top of the heap and sift up.

Return Value

TValue

The value of the extracted node.

bool insert(TValue $value)

Inserts an element in the heap by sifting it up.

Parameters

TValue $value

The value to insert.

Return Value

bool

TValue top()

Peeks at the node from the top of the heap

Return Value

TValue

The value of the node on the top.

int<0, max> count()

Counts the number of elements in the heap.

Return Value

int<0, max>

The custom count as an integer.

The return value is cast to an integer.

bool isEmpty()

Checks whether the heap is empty.

Return Value

bool

whether the heap is empty.

void rewind()

Rewind iterator back to the start (no-op)

Return Value

void

Any returned value is ignored.

TValue current()

Return current node pointed by the iterator

Return Value

TValue

Can return any type.

TKey|null key()

Return current node index

Return Value

TKey|null

TKey on success, or null on failure.

void next()

Move to the next node

Return Value

void

Any returned value is ignored.

bool valid()

Check whether the heap contains more nodes

Return Value

bool

The return value will be casted to boolean and then evaluated. Returns true on success or false on failure.

bool recoverFromCorruption()

Recover from the corrupted state and allow further actions on the heap.

Return Value

bool

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

Compare elements in order to place them correctly in the heap while sifting up.

Parameters

mixed $value1

The value of the first node being compared.

mixed $value2

The value of the second node being compared.

Return Value

int

Result of the comparison, positive integer if value1 is greater than value2, 0 if they are equal, negative integer otherwise.

Having multiple elements with the same value in a Heap is not recommended. They will end up in an arbitrary relative position.

bool isCorrupted()

No description

Return Value

bool

array __debugInfo()

Since: 7.4

No description

Return Value

array

array __serialize()

Since: 8.5

No description

Return Value

array

__unserialize(array $data)

Since: 8.5

No description

Parameters

array $data