Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

priority queues

priority queues

priority queues

I have been using queues in perl with the array data structure using push and shift commands. This works great but now i need to implemnt a prioity queue structure. Which means i cant be using an array anymore, i need to have a linked list. I am not sure how to make a link list in perl. Does any1 have any ideas?
please help thanks.

RE: priority queues

So, using push and shift you used standard arrays to hold data items...  You now want to assign, for want of a better phrase, a priority field to each item in your queue?  Would using a hash with the priority as the key value work for you?

For example:

$Queue{'1'} = "Most important item";
$Queue{'2'} = "A less important item";
$Queue{'100'} = "Bottom of the heap whatever else happens";

It should be fairly easy to create some function to insert/delete items from the queue, possibly re-numbering (re-keying) displaced queue items.  (Careful though, I've got a reputation for saying "It should be fairly easy..." just before a few days of head scratching... ;^)

0 1 - Just my two bits

RE: priority queues

That should work just as long as you make sure no two items can have the same priority :o)

Liam Morley
] :: imotic :: website :: [
"light the deep, and bring silence to the world.
light the world, and bring depth to the silence."

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close