php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #65170 SPLHeap next() removes current node
Submitted: 2013-06-30 21:36 UTC Modified: 2015-09-07 23:35 UTC
From: mark at lange dot demon dot co dot uk Assigned: levim (profile)
Status: Closed Package: SPL related
PHP Version: 5.3.26 OS: All
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mark at lange dot demon dot co dot uk
New email:
PHP Version: OS:

 

 [2013-06-30 21:36 UTC] 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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-07-03 21:52 UTC] 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-09-12 22:59 UTC] levim@php.net
-Type: Bug +Type: Documentation Problem
 [2014-04-17 14:54 UTC] 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
 [2015-09-07 23:35 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: levim
 [2015-09-07 23:35 UTC] cmb@php.net
Closing, as already been fixed.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 15:01:29 2024 UTC