[CODE] Priority Queues :: HowTo?

From: Justin Adler (spam@WORLD-DOMINATION.COM.AU)
Date: 02/11/02


Hello Folks.

   I have 2 questions about PRIORITY QUEUES.

1. How to impliment this in bpl20.
2. Is this the correct ALGORHYTHM for my situation?


Explanation
^^^^^^^^^^^
   I'm trying to impliment a list of rooms. The list is a fixed size (lets
say 1000 rooms max). The list needs to be prioritised, becuase i would like
the most 'important / common' rooms being near the head (ie. Highest
priority), while the least most common rooms down the end of the list.

   This way, when i enter the list, i do not have to traverse it (in
theory) all the way to the tail, becuase the most common rooms are found
near the head.

   If the room exists in the list (when i try to add a room to the list),
then the room will be 'trickle' up the list, getting closer to the head.

   If the room doesn't exist in the list, then it gets appended to the end
of the list.

   If the list is full, and the new room doesn't exist in the list (and
therefore needs to be appended to the list), then remove the last room, and
replace it with the new room.


   My research indicates a priority list is the name for the list i am
after.  Some research mentions BINARY HEAPS, but I *think* they are the
same thing - can someone please clarify that?

   So what i'm trying to find is some code that uses priority queues, so i
can add that to my stock code.  I would prefer not to 'reinvent the wheel'
as the cliche goes.

   Any help would be warmly welcomed :)


-Pure Krome-

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT