class SplPriorityQueue implements Iterator, Countable (View source)

Constants

EXTR_BOTH

EXTR_PRIORITY

EXTR_DATA

Methods

int
compare(TPriority $priority1, TPriority $priority2)

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

true
insert(TValue $value, TPriority $priority)

Inserts an element in the queue by sifting it up.

int
setExtractFlags(int $flags)

Sets the mode of extraction

TValue
top()

Peeks at the node from the top of the queue

TValue
extract()

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

int<0, max>
count()

Counts the number of elements in the queue.

bool
isEmpty()

Checks whether the queue 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 queue contains more nodes

recoverFromCorruption()

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

bool
isCorrupted()

No description

int
getExtractFlags()

No description

array
__debugInfo()

No description

array
__serialize()

No description

__unserialize(array $data)

No description

Details

int compare(TPriority $priority1, TPriority $priority2)

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

Parameters

TPriority $priority1

The priority of the first node being compared.

TPriority $priority2

The priority of the second node being compared.

Return Value

int

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

Multiple elements with the same priority will get dequeued in no particular order.

true insert(TValue $value, TPriority $priority)

Inserts an element in the queue by sifting it up.

Parameters

TValue $value

The value to insert.

TPriority $priority

The associated priority.

Return Value

true

int setExtractFlags(int $flags)

Sets the mode of extraction

Parameters

int $flags

Defines what is extracted by SplPriorityQueue::current, SplPriorityQueue::top and SplPriorityQueue::extract.

SplPriorityQueue::EXTR_DATA (0x00000001): Extract the data

Return Value

int

TValue top()

Peeks at the node from the top of the queue

Return Value

TValue

The value or priority (or both) of the top node, depending on the extract flag.

TValue extract()

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

Return Value

TValue

The value or priority (or both) of the extracted node, depending on the extract flag.

int<0, max> count()

Counts the number of elements in the queue.

Return Value

int<0, max>

The custom count as an integer.

The return value is cast to an integer.

bool isEmpty()

Checks whether the queue is empty.

Return Value

bool

whether the queue 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 queue 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.

recoverFromCorruption()

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

bool isCorrupted()

No description

Return Value

bool

int getExtractFlags()

No description

Return Value

int

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