Fully Qualified Name: | Laminas\Stdlib\FastPriorityQueue |
Implements: | Iterator, Countable, Serializable |
This is an efficient implementation of an integer priority queue in PHP
This class acts like a queue with insert() and extract(), removing the elements from the queue and it also acts like an Iterator without removing the elements. This behaviour can be used in mixed scenarios with high performance boost.
Name | Description | Defined By |
---|---|---|
contains() | Does the queue contain the given datum? | FastPriorityQueue |
count() | Get the total number of elements in the queue | FastPriorityQueue |
current() | Get the current element in the queue | FastPriorityQueue |
extract() | Extract an element in the queue according to the priority and the order of insertion | FastPriorityQueue |
hasPriority() | Does the queue have an item with the given priority? | FastPriorityQueue |
insert() | Insert an element in the queue with a specified priority | FastPriorityQueue |
isEmpty() | Check if the queue is empty | FastPriorityQueue |
key() | Get the index of the current element in the queue | FastPriorityQueue |
next() | Set the iterator pointer to the next element in the queue without removing the previous element | FastPriorityQueue |
remove() | Remove an item from the queue | FastPriorityQueue |
rewind() | Rewind the current iterator | FastPriorityQueue |
serialize() | Serialize | FastPriorityQueue |
setExtractFlags() | Set the extract flag | FastPriorityQueue |
toArray() | Serialize to an array | FastPriorityQueue |
unserialize() | Deserialize | FastPriorityQueue |
valid() | Check if the current iterator is valid | FastPriorityQueue |
Does the queue contain the given datum?
Parameter Name | Type | Description |
---|---|---|
$datum | mixed |
Returns: bool
Get the total number of elements in the queue
Returns: int
Get the current element in the queue
Returns: mixed
Extract an element in the queue according to the priority and the order of insertion
Returns: mixed
Does the queue have an item with the given priority?
Parameter Name | Type | Description |
---|---|---|
$priority | int |
Returns: bool
Insert an element in the queue with a specified priority
Parameter Name | Type | Description |
---|---|---|
$value | mixed | |
$priority | int |
Returns:
Check if the queue is empty
Returns: bool
Get the index of the current element in the queue
Returns: int
Set the iterator pointer to the next element in the queue without removing the previous element
Returns:
Remove an item from the queue
This is different than {@link extract()}; its purpose is to dequeue an item.
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.
Parameter Name | Type | Description |
---|---|---|
$datum | mixed |
Returns: bool False if the item was not found, true otherwise.
Rewind the current iterator
Returns:
Serialize
Returns: string
Set the extract flag
Parameter Name | Type | Description |
---|---|---|
$flag | int |
Returns:
Serialize to an array
Array will be priority => data pairs
Returns: array
Deserialize
Parameter Name | Type | Description |
---|---|---|
$data | string |
Returns: void
Check if the current iterator is valid
Returns: bool