summaryrefslogtreecommitdiff
path: root/ext/spl/tests/heap_001.phpt
blob: f9cfd68710ce1f93a4ec2f426ea8e84401779929 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
--TEST--
SPL: SplMaxHeap: std operations
--FILE--
<?php
$h = new SplMaxHeap();

// errors
try {
    $h->extract();
} catch (RuntimeException $e) {
    echo "Exception: ".$e->getMessage()."\n";
}


$h->insert(1);
$h->insert(2);
$h->insert(3);
$h->insert(3);
$h->insert(3);

echo $h->count()."\n";
echo $h->extract()."\n";
echo $h->extract()."\n";
echo $h->extract()."\n";
echo $h->extract()."\n";
echo $h->extract()."\n";
echo $h->count()."\n";

echo "--\n";

$b = 4;
$h->insert($b);
$b = 5;

$h2 = clone $h;
echo $h->extract()."\n";
echo $h2->extract()."\n";
?>
===DONE===
<?php exit(0); ?>
--EXPECT--
Exception: Can't extract from an empty heap
5
3
3
3
2
1
0
--
4
4
===DONE===