note 93999 added to splpriorityqueue.compare
| From: | Anonymous at osu1 dot php dot net | Date: | Sat, 10 Oct 2009 23:51:14 +0000 |
| Subject: | note 93999 added to splpriorityqueue.compare | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-161633@lists.php.net to get a copy of this message | ||
At this time, the documentation sais "Note: Multiple elements with the same priority will get
dequeued in no particular order."
If you need elements of equal priority to maintain insertion order, you can use something like:
<?php
class StablePriorityQueue extends SplPriorityQueue {
protected $serial = PHP_INT_MAX;
public function insert($value, $priority) {
parent::insert($value, array($priority, $this->serial--));
}
}
?>
----
Server IP: 192.41.40.227
Probable Submitter: 76.14.51.84
----
Manual Page -- http://www.php.net/manual/en/splpriorityqueue.compare.php
Edit -- https://master.php.net/note/edit/93999
Del: integrated -- https://master.php.net/note/delete/93999/integrated
Del: useless -- https://master.php.net/note/delete/93999/useless
Del: bad code -- https://master.php.net/note/delete/93999/bad+code
Del: spam -- https://master.php.net/note/delete/93999/spam
Del: non-english -- https://master.php.net/note/delete/93999/non-english
Del: in docs -- https://master.php.net/note/delete/93999/in+docs
Del: other reasons-- https://master.php.net/note/delete/93999
Reject -- https://master.php.net/note/reject/93999
Search -- https://master.php.net/manage/user-notes.php