Edit report at https://bugs.php.net/bug.php?id=65170&edit=1
ID: 65170 Comment by: cmbecker69 at gmx dot de Reported by: mark at lange dot demon dot co dot uk Summary: SPLHeap next() removes current node Status: Open Type: Bug Package: SPL related Operating System: All PHP Version: 5.3.26 Block user comment: N Private report: N New Comment: It seems to me this is rather a documentation issue (it should be noted that SplHeap::next() discards the top of the heap), as the documentation of SplHeap::rewind() shows. And that is consistent with the implementation, where spl_ptr_heap_delete_top() is explicitely called. Previous Comments: ------------------------------------------------------------------------ [2013-06-30 21:36:48] mark at lange dot demon dot co dot uk Description: ------------ When iterating through an SPLHeap, each node is removed from the heap as you loop through to the next node. Investigation has suggested that it is the next() method that removes the current node before moving to the next. Test script: --------------- https://gist.github.com/MarkBaker/5896053 Expected result: ---------------- There are 7 cities in the heap FROM NORTH TO SOUTH Newcastle upon Tyne +54.9833 -1.5833 Leeds +53.8100 -1.5500 Manchester +53.4800 -2.2400 Liverpool +53.4167 -3.0000 Birmingham +52.4800 -1.9100 London +51.5171 -0.1062 Bristol +51.4600 -2.6000 There are 7 cities in the heap There should be the same number of city nodes in the heap after iterating through as there were before. Actual result: -------------- There are 7 cities in the heap FROM NORTH TO SOUTH Newcastle upon Tyne +54.9833 -1.5833 Leeds +53.8100 -1.5500 Manchester +53.4800 -2.2400 Liverpool +53.4167 -3.0000 Birmingham +52.4800 -1.9100 London +51.5171 -0.1062 Bristol +51.4600 -2.6000 There are 0 cities in the heap However, there a 0 city nodes left in the heap after iterating through them. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=65170&edit=1