|
Queue::Base - Simple OO style queue implementation. |
Queue::Base - Simple OO style queue implementation.
use Queue::Base;
# construction my $queue = new Queue::Base; # or my $queue = new Queue::Base(\@elements);
# add a new element to the queue $queue->add($element);
# remove the next element from the queue
if (! $queue->empty()) {
my $element = $queue->remove();
}
# or
$element = $queue->remove();
if (defined $element) {
# do some processing here
}
# add/remove more than just one element $queue->add($elem1, $elem2 ...) # and @elements = $queue->remove(5);
The Queue::Base is a simple implementation for queue structures using an OO interface. Provides basic functionality: nothing less - nothing more.
ELEMENTS is an array reference with elements the queue to be initialized with.
In array context it attempts to return NUMBER_OF_ELEMENTS requested; when NUMBER_OF_ELEMENTS is not given, it defaults to 1.
The module works only with scalar values. If you want to use more complex structures (and there's a big change you want that) please use references, which in perl5 are basically scalars.
Farkas Arpad <arpadf@spidernet.co.ro>
|
Queue::Base - Simple OO style queue implementation. |