note 114959 added to class.splpriorityqueue
| From: | HayleyWatson | Date: | Tue, 06 May 2014 02:10:47 +0000 |
| Subject: | note 114959 added to class.splpriorityqueue | ||
| Groups: | php.notes php.notes | ||
| Request: | Send a blank email to php-notes+get-199423@lists.php.net to get a copy of this message | ||
For a heap-based priority queue to be at its most effective, the "priority" should be
something that can take on a wide range of values (lengths, timestamps, populations). It optimises
the tasks of searching the queue for the appropriate place to insert an item (and inserting it); and
removing the first item in the list.
Items may potentially be inserted into the queue wherever two adjacent items have different
priorities. The heap structure is an efficient way of indexing such insertion points when there are
many of them distributed throughout the list.
If you have a sharply-limited enumeration of possible priority values, then there are very few
insertion possible insertion points - one for each priority value. In that situation, one can make
the insertion points explicit (and thus eliminate the need to maintain a heap indexing them) by
implementing your priority queue as a list of simple queues from which you draw successive items
from the highest-priority nonempty queue.
----
Server IP: 202.78.240.39
Probable Submitter: 222.155.198.204
----
Manual Page -- http://php.net/manual/en/class.splpriorityqueue.php
Edit -- https://master.php.net/note/edit/114959
Del: integrated -- https://master.php.net/note/delete/114959/integrated
Del: useless -- https://master.php.net/note/delete/114959/useless
Del: bad code -- https://master.php.net/note/delete/114959/bad+code
Del: spam -- https://master.php.net/note/delete/114959/spam
Del: non-english -- https://master.php.net/note/delete/114959/non-english
Del: in docs -- https://master.php.net/note/delete/114959/in+docs
Del: other reasons-- https://master.php.net/note/delete/114959
Reject -- https://master.php.net/note/reject/114959
Search -- https://master.php.net/manage/user-notes.php