- AUTHORS & COPYRIGHTS
Hash::PriorityQueue - priority queue based on perl hashes
my $prio = Hash::PriorityQueue->new(); $prio->insert("foo", 2); $prio->insert("bar", 1); $prio->insert("baz", 3); my $next = $prio->pop(); # "bar" # I decided that "foo" isn't as important anymore $prio->update("foo", 99);
This module implements a high-performance priority queue, based on a hash. It's written in pure Perl.
Available functions are:
Adds the specified payload (anything fitting into a scalar) to the priority queue, using the specified priority. Smaller means more important.
If the item already exists in the queue, it is assigned the new priority.
These names are actually the same function. The alternative name is provided so you can make clear which operation you intended to be executed.
Removes the most important item (numerically lowest priority) from the queue and returns it. If no element is there, returns undef.
Deletes an item known by the specified payload from the queue.
Made 2010 by Lars Stoltenow. Hash::PriorityQueue is free software; you may redistribute it and/or modify it under the same terms as Perl itself.