Serializable version of SplPriorityQueue

Also, provides predictable heap order for datums added with the same priority (i.e., they will be emitted in the same order they are enqueued).

category Zend
package Zend_Stdlib
copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
license New BSD License
inherited_from \SplPriorityQueue

 Methods

Constructor

__construct() : void

Creates a new, empty queue

inherited_from \SplPriorityQueue::__construct()

Constructor

__construct() : void
Inherited

Creates a new, empty queue

Compare two priorities

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

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
Inherited

Returns

integer

Iterator: return current item

current() : mixed
Inherited

Returns

mixed

Extract a node from top of the heap and sift up

extract() : \mixed;
Inherited

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

Returns

\mixed;

Insert a value with a given priority

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

Utilizes {@var $serial} to ensure that values of equal priority are emitted in the same order in which they are inserted.

inherited_from \SplPriorityQueue::insert()

Parameters

$datum

mixed

$priority

mixed

Insert a value into the heap, at the specified priority

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

Parameters

$value

mixed

$priority

mixed

Is the queue currently empty?

isEmpty() : boolean
Inherited

Returns

boolean

Iterator: return current key

key() : mixed
Inherited

Returns

mixedUsually an int or string

Iterator: Move pointer forward

next() : void
Inherited

Recover from corrupted state and allow further actions on the queue

recoverFromCorruption() : void
Inherited

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

Iterator: Move pointer to first item

rewind() : void
Inherited

Serialize

serialize() : string

Returns

string

Set the extract flags

setExtractFlags(integer $flags) : void
Inherited

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

Serialize to an array

toArray() : array

Array will be priority => data pairs

Returns

array

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

top() : mixed
Inherited

Returns

mixed

Deserialize

unserialize(string $data) : void

Parameters

$data

string

Iterator: is the current position valid for the queue

valid() : boolean
Inherited

Returns

boolean

Prepare the queue for iteration and/or extraction

prepareQueue() : void
Inherited

Sort the queue

sort() : void
Inherited

 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
 

$isPhp53

$isPhp53 : boolean

Default

 

$preparedQueue

$preparedQueue : boolean | array

Default

false
 

All items in the queue

$queue : array

Default

array()
 

Seed used to ensure queue order for items of the same priority

$serial : integer

Default

PHP_INT_MAX

 Constants

 

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

EXTR_BOTH = 3 
 

Extract data only

EXTR_DATA = 1 
 

Extract priority only

EXTR_PRIORITY = 2