Stdlib/SplPriorityQueue.php

Show: PublicProtectedPrivateinherited
Table of Contents
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 license@zend.com 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

Package: Default
SplPriorityQueue

PHP 5.2.X userland implementation of PHP's SplPriorityQueue

Implements
Children
\Zend_Stdlib_SplPriorityQueue

Constants

>VConstant  EXTR_DATA = 1
Extract data only
>VConstant  EXTR_PRIORITY = 2
Extract priority only
>VConstant  EXTR_BOTH = 3
Extract an array of ('data' => $value, 'priority' => $priority)

Properties

>VPropertyprotectedint $count = 0
Count of items in the queue
Default value0Details
Type
int
>VPropertyprotectedint $extractFlags = self::EXTR_DATA
Flag indicating what should be returned when iterating or extracting
Default valueself::EXTR_DATADetails
Type
int
>VPropertyprotectedbool|array $preparedQueue = false
Default valuefalseDetails
Type
bool | array
>VPropertyprotectedarray $queue = array()
All items in the queue
Default valuearray()Details
Type
array

Methods

methodpublic__construct() : void

Constructor

Creates a new, empty queue

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

Parameters
NameTypeDescription
$priority1mixed
$priority2mixed
Returns
TypeDescription
int
methodpubliccount() : int

Countable: return number of items composed in the queue

Returns
TypeDescription
int
methodpubliccurrent() : mixed

Iterator: return current item

Returns
TypeDescription
mixed
methodpublicextract() : \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.

Returns
TypeDescription
\mixed;
methodpublicinsert(mixed $value, mixed $priority) : void

Insert a value into the heap, at the specified priority

Parameters
NameTypeDescription
$valuemixed
$prioritymixed
methodpublicisEmpty() : bool

Is the queue currently empty?

Returns
TypeDescription
bool
methodpublickey() : mixed

Iterator: return current key

Returns
TypeDescription
mixedUsually an int or string
methodpublicnext() : void

Iterator: Move pointer forward

methodprotectedprepareQueue() : void

Prepare the queue for iteration and/or extraction

methodpublicrecoverFromCorruption() : 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.

methodpublicrewind() : void

Iterator: Move pointer to first item

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

Parameters
NameTypeDescription
$flagsint
methodprotectedsort() : void

Sort the queue

methodpublictop() : mixed

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

Returns
TypeDescription
mixed
methodpublicvalid() : bool

Iterator: is the current position valid for the queue

Returns
TypeDescription
bool

\Zend_Stdlib_SplPriorityQueue

Package: Zend\Stdlib
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

>VConstant  EXTR_DATA = 1
inherited
Extract data only
Inherited from: \SplPriorityQueue::EXTR_DATA
>VConstant  EXTR_PRIORITY = 2
inherited
Extract priority only
Inherited from: \SplPriorityQueue::EXTR_PRIORITY
>VConstant  EXTR_BOTH = 3
inherited
Extract an array of ('data' => $value, 'priority' => $priority)
Inherited from: \SplPriorityQueue::EXTR_BOTH

Properties

>VPropertyprotectedint $count = 0
inherited
Count of items in the queue
Inherited from: \SplPriorityQueue::$$count
Default value0Details
Type
int
Inherited_from
\SplPriorityQueue::$$count  
>VPropertyprotectedint $extractFlags = self::EXTR_DATA
inherited
Flag indicating what should be returned when iterating or extracting
Inherited from: \SplPriorityQueue::$$extractFlags
Default valueself::EXTR_DATADetails
Type
int
Inherited_from
\SplPriorityQueue::$$extractFlags  
>VPropertyprotectedbool $isPhp53
Details
Type
bool
>VPropertyprotectedbool|array $preparedQueue = false
inherited
Inherited from: \SplPriorityQueue::$$preparedQueue
Default valuefalseDetails
Type
bool | array
Inherited_from
\SplPriorityQueue::$$preparedQueue  
>VPropertyprotectedarray $queue = array()
inherited
All items in the queue
Inherited from: \SplPriorityQueue::$$queue
Default valuearray()Details
Type
array
Inherited_from
\SplPriorityQueue::$$queue  
>VPropertyprotectedint $serial = PHP_INT_MAX

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

Default valuePHP_INT_MAXDetails
Type
int

Methods

methodpublic__construct() : void

Constructor

Creates a new, empty queue

methodpubliccompare(mixed $priority1, mixed $priority2) : int
inherited

Compare two priorities

Inherited from: \SplPriorityQueue::compare()

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
NameTypeDescription
$priority1mixed
$priority2mixed
Returns
TypeDescription
int
methodpubliccount() : int
inherited

Countable: return number of items composed in the queue

Inherited from: \SplPriorityQueue::count()
Returns
TypeDescription
int
methodpubliccurrent() : mixed
inherited

Iterator: return current item

Inherited from: \SplPriorityQueue::current()
Returns
TypeDescription
mixed
methodpublicextract() : \mixed;
inherited

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.

Returns
TypeDescription
\mixed;
methodpublicinsert(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.

Parameters
NameTypeDescription
$datummixed
$prioritymixed
methodpublicisEmpty() : bool
inherited

Is the queue currently empty?

Inherited from: \SplPriorityQueue::isEmpty()
Returns
TypeDescription
bool
methodpublickey() : mixed
inherited

Iterator: return current key

Inherited from: \SplPriorityQueue::key()
Returns
TypeDescription
mixedUsually an int or string
methodpublicnext() : void
inherited

Iterator: Move pointer forward

Inherited from: \SplPriorityQueue::next()
methodprotectedprepareQueue() : void
inherited

Prepare the queue for iteration and/or extraction

Inherited from: \SplPriorityQueue::prepareQueue()
methodpublicrecoverFromCorruption() : void
inherited

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.

methodpublicrewind() : void
inherited

Iterator: Move pointer to first item

Inherited from: \SplPriorityQueue::rewind()
methodpublicserialize() : string

Serialize

Returns
TypeDescription
string
methodpublicsetExtractFlags(int $flags) : void
inherited

Set the extract flags

Inherited from: \SplPriorityQueue::setExtractFlags()

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
NameTypeDescription
$flagsint
methodprotectedsort() : void
inherited

Sort the queue

Inherited from: \SplPriorityQueue::sort()
methodpublictoArray() : array

Serialize to an array

Array will be priority => data pairs

Returns
TypeDescription
array
methodpublictop() : mixed
inherited

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

Inherited from: \SplPriorityQueue::top()
Returns
TypeDescription
mixed
methodpublicunserialize(string $data) : void

Deserialize

Parameters
NameTypeDescription
$datastring
methodpublicvalid() : bool
inherited

Iterator: is the current position valid for the queue

Inherited from: \SplPriorityQueue::valid()
Returns
TypeDescription
bool
Documentation was generated by phpDocumentor 2.0.0a12.