php-src/ext/spl/tests/heap_011.phpt
2008-08-03 19:07:31 +00:00

32 lines
551 B
PHP

--TEST--
SPL: SplHeap with overriden compare()
--FILE--
<?php
class SplMinHeap2 extends SplMinHeap {
public function compare($a, $b) {
return -parent::compare($a,$b);
}
}
$h = new SplMinHeap2();
$h->insert(1);
$h->insert(6);
$h->insert(5);
$h->insert(2);
var_dump($h->top());
class SplMaxHeap2 extends SplMaxHeap {
public function compare($a, $b) {
return -parent::compare($a,$b);
}
}
$h = new SplMaxHeap2();
$h->insert(1);
$h->insert(6);
$h->insert(5);
$h->insert(2);
var_dump($h->top());
?>
--EXPECT--
int(6)
int(1)