heap_007.phpt 411 B

1234567891011121314151617181920212223242526272829
  1. --TEST--
  2. SPL: SplHeap: iteration through methods
  3. --FILE--
  4. <?php
  5. $h = new SplMaxHeap();
  6. $h->insert(1);
  7. $h->insert(5);
  8. $h->insert(0);
  9. $h->insert(4);
  10. $h->rewind();
  11. echo "count(\$h) = ".count($h)."\n";
  12. echo "\$h->count() = ".$h->count()."\n";
  13. while ($h->valid()) {
  14. $k = $h->key();
  15. $v = $h->current();
  16. echo "$k=>$v\n";
  17. $h->next();
  18. }
  19. ?>
  20. --EXPECT--
  21. count($h) = 4
  22. $h->count() = 4
  23. 3=>5
  24. 2=>4
  25. 1=>1
  26. 0=>0