Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
17
Task/Priority-queue/PHP/priority-queue-1.php
Normal file
17
Task/Priority-queue/PHP/priority-queue-1.php
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
$pq = new SplPriorityQueue;
|
||||
|
||||
$pq->insert('Clear drains', 3);
|
||||
$pq->insert('Feed cat', 4);
|
||||
$pq->insert('Make tea', 5);
|
||||
$pq->insert('Solve RC tasks', 1);
|
||||
$pq->insert('Tax return', 2);
|
||||
|
||||
// This line causes extract() to return both the data and priority (in an associative array),
|
||||
// Otherwise it would just return the data
|
||||
$pq->setExtractFlags(SplPriorityQueue::EXTR_BOTH);
|
||||
|
||||
while (!$pq->isEmpty()) {
|
||||
print_r($pq->extract());
|
||||
}
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue