From:
Operating system: Ubuntu
PHP version: 5.4.0RC6
Package: SPL related
Bug Type: Feature/Change Request
Bug description:LIFO/FIFO iterator modes for priority queues
Description:
------------
PHP version is actually PHP5.4RC3
It would be nice to be able to maintain the input order in a SPL priority
queue when multiple values share the same priority.
E.g. FIFO and LIFO
The current "mode" is neither one of these. I guess this is best
peformance-wise but sometimes you want to be explicitly, for instance when
registering event listeners; you expect them to run in order.
Test script:
---------------
<?php
$queue = new \SplPriorityQueue;
$queue->insert('a', 100);
$queue->insert('b', 100);
$queue->insert('c', 110);
$queue->insert('d', 90);
foreach($queue as $element) {
var_dump($element);
echo '<br>';
}
echo '<br>';
$queue2 = new \SplPriorityQueue;
$queue2->insert('a', 100);
$queue2->insert('b', 100);
foreach($queue2 as $element) {
var_dump($element);
echo '<br>';
}
Expected result:
----------------
string(1) "c"
string(1) "a"
string(1) "b"
string(1) "d"
string(1) "a"
string(1) "b"
Actual result:
--------------
string(1) "c"
string(1) "b"
string(1) "a"
string(1) "d"
string(1) "a"
string(1) "b"
--
Edit bug report at https://bugs.php.net/bug.php?id=60926&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=60926&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=60926&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=60926&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=60926&r=fixed
Fixed in SVN and need be documented:
https://bugs.php.net/fix.php?id=60926&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=60926&r=alreadyfixed
Need backtrace:
https://bugs.php.net/fix.php?id=60926&r=needtrace
Need Reproduce Script:
https://bugs.php.net/fix.php?id=60926&r=needscript
Try newer version:
https://bugs.php.net/fix.php?id=60926&r=oldversion
Not developer issue:
https://bugs.php.net/fix.php?id=60926&r=support
Expected behavior:
https://bugs.php.net/fix.php?id=60926&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=60926&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=60926&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=60926&r=globals
PHP 4 support discontinued:
https://bugs.php.net/fix.php?id=60926&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=60926&r=dst
IIS Stability:
https://bugs.php.net/fix.php?id=60926&r=isapi
Install GNU Sed:
https://bugs.php.net/fix.php?id=60926&r=gnused
Floating point limitations:
https://bugs.php.net/fix.php?id=60926&r=float
No Zend Extensions:
https://bugs.php.net/fix.php?id=60926&r=nozend
MySQL Configuration Error:
https://bugs.php.net/fix.php?id=60926&r=mysqlcfg