Stdlib/SplPriorityQueue.php
Zend Framework
LICENSE
This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to [email protected] so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Stdlib
\SplPriorityQueue
SplPriorityQueue
PHP 5.2.X userland implementation of PHP's SplPriorityQueue
- Implements
- Children
- \Zend_Stdlib_SplPriorityQueue
Constants
Properties


int $extractFlags = self::EXTR_DATA
Flag indicating what should be returned when iterating or extracting
self::EXTR_DATA
Details- Type
- int
Methods


compare(mixed $priority1, mixed $priority2) : int
Compare two priorities
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.
Name | Type | Description |
---|---|---|
$priority1 | mixed | |
$priority2 | mixed |
Type | Description |
---|---|
int |


extract() : \mixed;
Extract a node from top of the heap and sift up
Returns either the value, the priority, or both, depending on the extract flag.
Type | Description |
---|---|
\mixed; |


insert(mixed $value, mixed $priority) : void
Insert a value into the heap, at the specified priority
Name | Type | Description |
---|---|---|
$value | mixed | |
$priority | mixed |


recoverFromCorruption() : void
Recover from corrupted state and allow further actions on the queue
Unimplemented, and only included in order to retain the same interface as PHP's SplPriorityQueue.


setExtractFlags(int $flags) : void
Set the extract flags
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.
Name | Type | Description |
---|---|---|
$flags | int |


top() : mixed
Return the value or priority (or both) of the top node, depending on the extract flag
Type | Description |
---|---|
mixed |
\Zend_Stdlib_SplPriorityQueue
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).
- Implements
- Parent(s)
- \SplPriorityQueue
- Children
- \Zend_EventManager_Filter_FilterIterator
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Constants

EXTR_BOTH
= 3
Extract an array of ('data' => $value, 'priority' => $priority)
Inherited from: \SplPriorityQueue::EXTR_BOTH- Inherited_from
- \SplPriorityQueue::EXTR_BOTH
Properties


int $extractFlags = self::EXTR_DATA
Flag indicating what should be returned when iterating or extracting
Inherited from: \SplPriorityQueue::$$extractFlagsself::EXTR_DATA
Details- Type
- int
- Inherited_from
- \SplPriorityQueue::$$extractFlags


bool|array $preparedQueue = false
false
Details- Type
- bool | array
- Inherited_from
- \SplPriorityQueue::$$preparedQueue


array $queue = array()
array()
Details- Type
- array
- Inherited_from
- \SplPriorityQueue::$$queue
Methods


compare(mixed $priority1, mixed $priority2) : int
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.
Name | Type | Description |
---|---|---|
$priority1 | mixed | |
$priority2 | mixed |
Type | Description |
---|---|
int |


count() : int
Countable: return number of items composed in the queue
Inherited from: \SplPriorityQueue::count()Type | Description |
---|---|
int |


extract() : \mixed;
Extract a node from top of the heap and sift up
Inherited from: \SplPriorityQueue::extract()Returns either the value, the priority, or both, depending on the extract flag.
Type | Description |
---|---|
\mixed; |


insert(mixed $datum, mixed $priority) : void
Insert a value with a given priority
Utilizes {@var $serial} to ensure that values of equal priority are emitted in the same order in which they are inserted.
Name | Type | Description |
---|---|---|
$datum | mixed | |
$priority | mixed |


prepareQueue() : void
Prepare the queue for iteration and/or extraction
Inherited from: \SplPriorityQueue::prepareQueue()

recoverFromCorruption() : void
Recover from corrupted state and allow further actions on the queue
Inherited from: \SplPriorityQueue::recoverFromCorruption()Unimplemented, and only included in order to retain the same interface as PHP's SplPriorityQueue.


setExtractFlags(int $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.
Name | Type | Description |
---|---|---|
$flags | int |


toArray() : array
Serialize to an array
Array will be priority => data pairs
Type | Description |
---|---|
array |


top() : mixed
Return the value or priority (or both) of the top node, depending on the extract flag
Inherited from: \SplPriorityQueue::top()Type | Description |
---|---|
mixed |


valid() : bool
Iterator: is the current position valid for the queue
Inherited from: \SplPriorityQueue::valid()Type | Description |
---|---|
bool |