class SplMaxHeap extends SplHeap (View source)

Methods

mixed
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
mixed
top()

Peeks at the node from the top of the heap

from  SplHeap
int
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
mixed
current()

Return current node pointed by the iterator

from  SplHeap
mixed
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

Details

mixed extract()

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

Return Value

mixed

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

mixed top()

Peeks at the node from the top of the heap

Return Value

mixed

The value of the node on the top.

int count()

Counts the number of elements in the heap.

Return Value

int

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.

mixed current()

Return current node pointed by the iterator

Return Value

mixed

Can return any type.

mixed key()

Return current node index

Return Value

mixed

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