|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2012-01-30 03:09 UTC] carloschilazo at gmail dot com
[2012-01-30 18:23 UTC] franssen dot roland at gmail dot com
[2012-01-30 18:53 UTC] franssen dot roland at gmail dot com
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 20:00:01 2025 UTC |
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"