xref: /PHP-5.6/ext/spl/tests/spl_pq_top_basic.phpt (revision 6f75314b)
1--TEST--
2SPL: SplPriorityQueue: top and extract flags
3--CREDITS--
4Nathaniel McHugh nat@fishtrap.co.uk
5#testfest London 2009-05-09
6--FILE--
7<?php
8
9$priorityQueue = new SplPriorityQueue();
10
11$priorityQueue->insert("a", 1);
12$priorityQueue->insert("b", 2);
13$priorityQueue->insert("c", 0);
14
15echo "EXTR DEFAULT",PHP_EOL;
16echo "value: ",$priorityQueue->top(),PHP_EOL;
17
18$priorityQueue->setExtractFlags(SplPriorityQueue::EXTR_PRIORITY);
19echo "EXTR_PRIORITY",PHP_EOL;
20echo "priority: ",$priorityQueue->top(),PHP_EOL;
21
22$priorityQueue->setExtractFlags(SplPriorityQueue::EXTR_BOTH);
23echo "EXTR_BOTH",PHP_EOL;
24print_r($priorityQueue->top());
25
26echo "EXTR_DATA",PHP_EOL;
27$priorityQueue->setExtractFlags(SplPriorityQueue::EXTR_DATA);
28echo "value: ",$priorityQueue->top(),PHP_EOL;
29?>
30--EXPECT--
31EXTR DEFAULT
32value: b
33EXTR_PRIORITY
34priority: 2
35EXTR_BOTH
36Array
37(
38    [data] => b
39    [priority] => 2
40)
41EXTR_DATA
42value: b