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

mixed
top()

Peeks at the node from the top of the queue

mixed
extract()

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

int
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)

mixed
current()

Return current node pointed by the iterator

mixed
key()

Return current node index

void
next()

Move to the next node

bool
valid()

Check whether the queue contains more nodes

true
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

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

mixed top()

Peeks at the node from the top of the queue

Return Value

mixed

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

mixed extract()

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

Return Value

mixed

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

int count()

Counts the number of elements in the queue.

Return Value

int

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.

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 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.

true recoverFromCorruption()

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

Return Value

true

bool isCorrupted()

No description

Return Value

bool

int getExtractFlags()

No description

Return Value

int

array __debugInfo()

Since: 7.4

No description

Return Value

array