Bug #55185 [Opn->Bgs]: SplMaxHeap only once loopable

From: Date: Tue, 12 Jul 2011 08:28:45 +0000
Subject: Bug #55185 [Opn->Bgs]: SplMaxHeap only once loopable
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-161819@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=55185&edit=1 ID: 55185 Updated by: scottmac@php.net Reported by: janwalther86 at gmail dot com Summary: SplMaxHeap only once loopable -Status: Open +Status: Bogus Type: Bug Package: SPL related PHP Version: 5.3.6 Block user comment: N Private report: N New Comment: As it iterates over a heap it extracts the number from it. Previous Comments: ------------------------------------------------------------------------ [2011-07-12 04:19:23] janwalther86 at gmail dot com 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 this bug report at https://bugs.php.net/bug.php?id=55185&edit=1

« previous php.bugs (#161819) next »