class SplMaxHeap extends SplHeap (View source)

Methods

TValue
extract()

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

from  SplHeap
bool
insert(TValue $value)

Inserts an element in the heap by sifting it up.

from  SplHeap
TValue
top()

Peeks at the node from the top of the heap

from  SplHeap
int<0, max>
count()

Counts the number of elements in the heap.

from  SplHeap
bool
isEmpty()

Checks whether the heap is empty.

from  SplHeap
void
rewind()

Rewind iterator back to the start (no-op)

from  SplHeap
TValue
current()

Return current node pointed by the iterator

from  SplHeap
TKey|null
key()

Return current node index

from  SplHeap
void
next()

Move to the next node

from  SplHeap
bool
valid()

Check whether the heap contains more nodes

from  SplHeap
bool
recoverFromCorruption()

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

from  SplHeap
int
compare(mixed $value1, mixed $value2)

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

bool
isCorrupted()

No description

from  SplHeap
array
__debugInfo()

No description

from  SplHeap
array
__serialize()

No description

from  SplHeap
__unserialize(array $data)

No description

from  SplHeap

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

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