Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sysread/queue-priority
https://github.com/sysread/queue-priority
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/sysread/queue-priority
- Owner: sysread
- License: other
- Created: 2015-12-08T18:18:44.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-12-08T18:39:21.000Z (about 9 years ago)
- Last Synced: 2023-03-23T22:19:38.658Z (almost 2 years ago)
- Language: Perl
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- Changelog: Changes
- License: COPYING
Awesome Lists containing this project
README
NAME
Queue::PrioritySYNOPSIS
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 OberCOPYRIGHT 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.