NAME Queue::Priority SYNOPSIS use Queue::Priority; use List::Util qw( shuffle ); my $queue = Queue::Priority->new( 10 ); foreach my $i ( shuffle 1 .. 10 ) { $queue->insert( $i ); } while (1) { my $i = $queue->remove or last; printf "%d * 2 = %d\n", $i, $i * 2; } DESCRIPTION Priority queues automatically order their contents according to the inserted item's priority. Calling code must ensure that their queue items are comparable via this strategy (e.g. by overloading the <=> operator). This module is implemented as an array heap. METHODS new Creates a new queue that can store $max items. count Returns the number of items currently stored. is_empty Returns true if the queue is empty. is_full Returns true if the queue is full. peek Returns the first (highest priority) element in the queue without removing it from the queue. is_shutdown Returns true if the queue has been shut down. shutdown Shuts down the queue, after which no items may be inserted. Items already in the queue can be pulled normally until empty, after which further calls to "remove" will return undefined. insert Inserts an item into the queue. Dies if the queue is full, has been shut down, or if the only argument is undefined. remove Removes and returns an item from the queue. If the queue is empty or shutdown, returns undefined immediately. DEBUG dump Prints an indented representation of the heap structure. AUTHOR Jeff Ober COPYRIGHT AND LICENSE This software is copyright (c) 2015 by Jeff Ober. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.