]> granicus.if.org Git - php/commitdiff
- MFH
authorDavid Coallier <davidc@php.net>
Sat, 22 Nov 2008 14:19:47 +0000 (14:19 +0000)
committerDavid Coallier <davidc@php.net>
Sat, 22 Nov 2008 14:19:47 +0000 (14:19 +0000)
- Bug #46615
- Return the count - 1 when invoking SplHeap->key()
- Adjusted the tests

ext/spl/spl_heap.c
ext/spl/tests/heap_007.phpt
ext/spl/tests/pqueue_003.phpt

index fe82d8164482b46931ec1018e2b560a1f7b857e3..f073597af12b894b8a2c3048b5ceab68046e5cbc 100644 (file)
@@ -970,8 +970,8 @@ static void spl_heap_it_move_forward(zend_object_iterator *iter TSRMLS_DC) /* {{
 SPL_METHOD(SplHeap, key)
 {
        spl_heap_object *intern = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
-
-       RETURN_LONG(intern->heap->count);
+       
+       RETURN_LONG(intern->heap->count - 1);
 }
 /* }}} */
 
index 784ac6e8b0b0ee853cb3950ac6b3c57cbc123c9c..e8d5c9997cfcbffc6aa83afade337fa8d7c3fdcb 100644 (file)
@@ -12,6 +12,7 @@ $h->insert(4);
 $h->rewind();
 echo "count(\$h) = ".count($h)."\n";
 echo "\$h->count() = ".$h->count()."\n";
+
 while ($h->valid()) {
     $k = $h->key();
     $v = $h->current();
@@ -24,8 +25,8 @@ while ($h->valid()) {
 --EXPECTF--
 count($h) = 4
 $h->count() = 4
-4=>5
-3=>4
-2=>1
-1=>0
+3=>5
+2=>4
+1=>1
+0=>0
 ===DONE===
index 8abc72c4c77a2e06035e93db68b08f54812b2e08..9c0b5a5147cfb385dde3289288be0e9135f72714 100644 (file)
@@ -24,8 +24,8 @@ while ($h->valid()) {
 --EXPECTF--
 count($h) = 4
 $h->count() = 4
-4=>5
-3=>4
-2=>1
-1=>0
+3=>5
+2=>4
+1=>1
+0=>0
 ===DONE===