Bug #55185 [NEW]: SplMaxHeap only once loopable

From: Date: Tue, 12 Jul 2011 08:19:23 +0000
Subject: Bug #55185 [NEW]: SplMaxHeap only once loopable
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-161818@lists.php.net to get a copy of this message
From:             
Operating system: 
PHP version:      5.3.6
Package:          SPL related
Bug Type:         Bug
Bug description:SplMaxHeap only once loopable

Description:
------------
I tried to loop through a SplMaxHeap object multiple times but it only
loops once. As there is no option to reset or rewind the heap object I
don't see a way to loop through it multiple times.

I noticed that $heap->count() decreases with every loop cycle, perhaps that
is the reason.

Test script:
---------------
$heap = new SplMaxHeap();
$heap->insert(1);
$heap->insert(2);
foreach($heap as $number){
  echo $number."\n";
}
foreach($heap as $number){
  echo $number."\n";
}



Expected result:
----------------
2
1
2
1


Actual result:
--------------
2
1


-- 
Edit bug report at https://bugs.php.net/bug.php?id=55185&edit=1
-- 
Try a snapshot (PHP 5.2):            https://bugs.php.net/fix.php?id=55185&r=trysnapshot52
Try a snapshot (PHP 5.3):            https://bugs.php.net/fix.php?id=55185&r=trysnapshot53
Try a snapshot (trunk):              https://bugs.php.net/fix.php?id=55185&r=trysnapshottrunk
Fixed in SVN:                        https://bugs.php.net/fix.php?id=55185&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=55185&r=needdocs
Fixed in release:                    https://bugs.php.net/fix.php?id=55185&r=alreadyfixed
Need backtrace:                      https://bugs.php.net/fix.php?id=55185&r=needtrace
Need Reproduce Script:               https://bugs.php.net/fix.php?id=55185&r=needscript
Try newer version:                   https://bugs.php.net/fix.php?id=55185&r=oldversion
Not developer issue:                 https://bugs.php.net/fix.php?id=55185&r=support
Expected behavior:                   https://bugs.php.net/fix.php?id=55185&r=notwrong
Not enough info:                     https://bugs.php.net/fix.php?id=55185&r=notenoughinfo
Submitted twice:                     https://bugs.php.net/fix.php?id=55185&r=submittedtwice
register_globals:                    https://bugs.php.net/fix.php?id=55185&r=globals
PHP 4 support discontinued:          https://bugs.php.net/fix.php?id=55185&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=55185&r=dst
IIS Stability:                       https://bugs.php.net/fix.php?id=55185&r=isapi
Install GNU Sed:                     https://bugs.php.net/fix.php?id=55185&r=gnused
Floating point limitations:          https://bugs.php.net/fix.php?id=55185&r=float
No Zend Extensions:                  https://bugs.php.net/fix.php?id=55185&r=nozend
MySQL Configuration Error:           https://bugs.php.net/fix.php?id=55185&r=mysqlcfg
Try a snapshot (PHP 5.4):            https://bugs.php.net/fix.php?id=55185&r=trysnapshot54



Thread (2 messages)

« previous php.bugs (#161818) next »