SplPriorityQueue

PHP 5.2.X userland implementation of PHP's SplPriorityQueue

package Zend_Stdlib

 Methods

Constructor

__construct() : void

Creates a new, empty queue

Compare two priorities

compare(mixed $priority1, mixed $priority2) : integer

Returns positive integer if $priority1 is greater than $priority2, 0 if equal, negative otherwise.

Unused internally, and only included in order to retain the same interface as PHP's SplPriorityQueue.

Parameters

$priority1

mixed

$priority2

mixed

Returns

integer

Countable: return number of items composed in the queue

count() : integer

Returns

integer

Iterator: return current item

current() : mixed

Returns

mixed

Extract a node from top of the heap and sift up

extract() : \mixed;

Returns either the value, the priority, or both, depending on the extract flag.

Returns

\mixed;

Insert a value into the heap, at the specified priority

insert(mixed $value, mixed $priority) : void

Parameters

$value

mixed

$priority

mixed

Is the queue currently empty?

isEmpty() : boolean

Returns

boolean

Iterator: return current key

key() : mixed

Returns

mixedUsually an int or string

Iterator: Move pointer forward

next() : void

Recover from corrupted state and allow further actions on the queue

recoverFromCorruption() : void

Unimplemented, and only included in order to retain the same interface as PHP's SplPriorityQueue.

Iterator: Move pointer to first item

rewind() : void

Set the extract flags

setExtractFlags(integer $flags) : void

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

  • SplPriorityQueue::EXTR_DATA (0x00000001): Extract the data
  • SplPriorityQueue::EXTR_PRIORITY (0x00000002): Extract the priority
  • SplPriorityQueue::EXTR_BOTH (0x00000003): Extract an array containing both

The default mode is SplPriorityQueue::EXTR_DATA.

Parameters

$flags

integer

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

top() : mixed

Returns

mixed

Iterator: is the current position valid for the queue

valid() : boolean

Returns

boolean

Prepare the queue for iteration and/or extraction

prepareQueue() : void

Sort the queue

sort() : void

 Properties

 

Count of items in the queue

$count : integer

Default

0
 

Flag indicating what should be returned when iterating or extracting

$extractFlags : integer

Default

self::EXTR_DATA
 

$preparedQueue

$preparedQueue : boolean | array

Default

false
 

All items in the queue

$queue : array

Default

array()

 Constants

 

Extract an array of ('data' => $value, 'priority' => $priority)

EXTR_BOTH = 3 
 

Extract data only

EXTR_DATA = 1 
 

Extract priority only

EXTR_PRIORITY = 2