The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Hash::PriorityQueue - priority queue based on perl hashes

SYNOPSIS

 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);

DESCRIPTION

This module implements a high-performance priority queue, based on a hash. It's written in pure Perl.

Available functions are:

new()

Obvious.

insert($payload, $priority)

update($payload, $new_priority)

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.

pop()

Removes the most important item (numerically lowest priority) from the queue and returns it. If no element is there, returns undef.

delete($payload)

Deletes an item known by the specified payload from the queue.

BUGS

Maybe.

AUTHORS & COPYRIGHTS

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.