NAME

Labrador::Common::SlicedQueue

SYPNOPSIS

	my $arr = new Labrador::Common::SlicedQueue([],[], []);
	$arr->push(0, 'ab');
	$arr->push(0, 'ac');
	#print $arr->dump;
	$arr->unshift(0,'aa');
	$arr->push(1, 'bb');
	#print $arr->dump;
	$arr->unshift(1, 'ba');
	$arr->push(1, 'bc');
	$arr->push(2, 'cc');
	$arr->unshift(2, 'cb');
	$arr->unshift(2, 'ca');
	$arr->push(2, 'cd');
	$arr->push(5, 'fa');
	$arr->push(3, 'db');
	$arr->push(4, 'ea');
	#$arr->pop(2); #remove cd
	$arr->pop(5); #remove fa, remove 5;
	#$arr->pop(3); #remove db
	$arr->shift(0); #remove aa
	$arr->shift(3); #remove db, 3 empty
	$arr->shift(4); #remove ea, remove 4,5
	print $arr->dump;

DESCRIPTION

This object allows N lists to be kept in one object, using only three arrays for internal representation. Operations allowed on a list are push, shift, pop, unshift, get, remove.

Essentially, this object encapsulates multi-dimensional arrays in single-dimension arrays.

INTERNALS

This object is represented by a blessed array reference, with three elements. These are, in order: Data of all arrays, Sizes of each array, the upper bound of each array.

METHODS

new([$DataArrayRef, $SizesArrayRef, $UpperBoundsArrayRef])

Construct a new SlicedQueue. If external arrays are wished to be used for internal representation, pass these as the parameters to the constructor. (Ie, if you wish tied arrays for persistence).

push($queue, @list)

Push @list onto the end of queue number $queue

unshift($queue, @list)

Prepend @list onto the front of queue number $queue

remove($queue)

Remove the contents of queue number $queue. Returns deleted values.

pop($queue)

Remove an item from the end of queue number $queue.

shift($queue)

Remove an item from the front of queue number $queue.

get($queue)

Returns the entire contents of queue number $queue.

size($queue)

Returns the size of queue number $queue.

total_size()
queues()

Returns the number of queues

dump()

Returns a textual representation of the queues.

REVISION

	$Revision: 1.3 $