Help-Site Computer Manuals
Software
Hardware
Programming
Networking
  Algorithms & Data Structures   Programming Languages   Revision Control
  Protocols
  Cameras   Computers   Displays   Keyboards & Mice   Motherboards   Networking   Printers & Scanners   Storage
  Windows   Linux & Unix   Mac

Queue::Base
Simple OO style queue implementation.

Queue::Base - Simple OO style queue implementation.


NAME

Queue::Base - Simple OO style queue implementation.


SYNOPSIS


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


DESCRIPTION

The Queue::Base is a simple implementation for queue structures using an OO interface. Provides basic functionality: nothing less - nothing more.


METHODS

Constructor

new [ELEMENTS]
Creates a new empty queue.

ELEMENTS is an array reference with elements the queue to be initialized with.

Methods

add [LIST_OF_ELEMENTS]
Adds the LIST OF ELEMENTS to the end of the queue.

remove [NUMBER_OF_ELEMENTS]
In scalar context it returns the first element from the queue.

In array context it attempts to return NUMBER_OF_ELEMENTS requested; when NUMBER_OF_ELEMENTS is not given, it defaults to 1.

size
Returns the size of the queue.

empty
Returns whether the queue is empty, which means its size is 0.

clear
Removes all elements from the queue.


CAVEATS

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.


AUTHOR

Farkas Arpad <arpadf@spidernet.co.ro>

Programminig
Wy
Wy
yW
Wy
Programming
Wy
Wy
Wy
Wy