Stdlib/PriorityQueue.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-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Stdlib
\Zend_Stdlib_PriorityQueue
Package: Zend_StdlibRe-usable, serializable priority queue implementation
SplPriorityQueue acts as a heap; on iteration, each item is removed from the
queue. If you wish to re-use such a queue, you need to clone it first. This
makes for some interesting issues if you wish to delete items from the queue,
or, as already stated, iterate over it multiple times.
This class aggregates items for the queue itself, but also composes an
"inner" iterator in the form of an SplPriorityQueue object for performing
the actual iteration.
- Implements
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Constants
Properties
array $items = array()
Actual items aggregated in the priority queue. Each item is an array
with keys "data" and "priority".
Default valuearray()
Details- Type
- array
string $queueClass = 'Zend_Stdlib_SplPriorityQueue'
Inner queue class to use for iteration
Default value'Zend_Stdlib_SplPriorityQueue'
Details- Type
- string
Methods
contains(mixed $datum) : bool
Does the queue contain the given datum?
ParametersName | Type | Description |
---|
$datum | mixed | |
---|
Returns getIterator() : \SplPriorityQueue
Retrieve the inner iterator
SplPriorityQueue acts as a heap, which typically implies that as items
are iterated, they are also removed. This does not work for situations
where the queue may be iterated multiple times. As such, this class
aggregates the values, and also injects an SplPriorityQueue. This method
retrieves the inner queue object, and clones it for purposes of
iteration.
ReturnshasPriority(int $priority) : bool
Does the queue have an item with the given priority?
ParametersName | Type | Description |
---|
$priority | int | |
---|
Returns insert(mixed $data, int $priority = 1) : \Zend_Stdlib_PriorityQueue
Insert an item into the queue
Priority defaults to 1 (low priority) if none provided.
ParametersName | Type | Description |
---|
$data | mixed | |
---|
$priority | int | |
---|
Returnsremove(mixed $datum) : boolean
Remove an item from the queue
This is different than {@link extract()}; its purpose is to dequeue an
item.
This operation is potentially expensive, as it requires
re-initialization and re-population of the inner queue.
Note: this removes the first item matching the provided item found. If
the same item has been added multiple times, it will not remove other
instances.
ParametersName | Type | Description |
---|
$datum | mixed | |
---|
ReturnsType | Description |
---|
boolean | False if the item was not found, true otherwise. |
returnData(array $item) : mixed
Return data from an internal item
Used as a lambda in toArray().
ParametersName | Type | Description |
---|
$item | array | |
---|
ReturnsreturnPriority(array $item) : mixed
Return priority from an internal item
Used as a lambda in toArray().
ParametersName | Type | Description |
---|
$item | array | |
---|
ReturnssetInternalQueueClass(string $class) : \Zend_Stdlib_PriorityQueue
Specify the internal queue class
Please see {@link getIterator()} for details on the necessity of an
internal queue class. The class provided should extend SplPriorityQueue.
ParametersName | Type | Description |
---|
$class | string | |
---|
Returnsunserialize(string $data) : void
Unserialize a string into a Zend_Stdlib_PriorityQueue object
Serialization format is compatible with {@link Zend_Stdlib_SplPriorityQueue}
ParametersName | Type | Description |
---|
$data | string | |
---|