Doc #65170 [Opn->Csd]: SPLHeap next() removes current node
| From: | cmb@php.net | Date: | Mon, 07 Sep 2015 23:35:03 +0000 |
| Subject: | Doc #65170 [Opn->Csd]: SPLHeap next() removes current node | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-12732@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65170&edit=1
ID: 65170
Updated by: cmb@php.net
Reported by: mark at lange dot demon dot co dot uk
Summary: SPLHeap next() removes current node
-Status: Open
+Status: Closed
Type: Documentation Problem
Package: SPL related
Operating System: All
PHP Version: 5.3.26
-Assigned To:
+Assigned To: levim
Block user comment: N
Private report: N
New Comment:
Closing, as already been fixed.
Previous Comments:
------------------------------------------------------------------------
[2014-04-17 14:54:01] levim@php.net
Automatic comment from SVN on behalf of levim
Revision: http://svn.php.net/viewvc/?view=revision&revision=333362
Log: Fixes bug 65170
------------------------------------------------------------------------
[2013-07-03 21:52:26] cmbecker69 at gmx dot de
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.
------------------------------------------------------------------------
[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