NAME

Array::LIFO - Last-in, First-out array

VERSION

version 0.01

SYNOPSIS

use Array::LIFO;
my $ar = Array::LIFO->new( max_size => 12 );
$ar->add(20);
$ar->add(18);
$ar->add(22);
print $ar->size, "\n";
print $ar->average, "\n";
print $ar->sum, "\n";
$ar->remove;
print "@{ $ar->queue }\n";

DESCRIPTION

An Array::LIFO allows the declaration of an array with last-in, first-out operation. That is, a "stack."

NAME

Array::LIFO - Last-in, First-out array

METHODS

new()

$x = Array::LIFO->new;
$x = Array::LIFO->new( max_size => $m );
max_size (optional)

Numeric value of how large the array is allowed to get. When it reaches max_size, new items are not added.

If no value is passed, there is no max size.

add

$ar->add($x);

You can add any type of item to the array. If the element is not a number it will be ignored by the sum() and average() calculations.

remove

$ar->remove;

Remove the last item on the array.

size

$ar->size;

How many elements are in the array.

max_size

$ar->max_size;

The maximum size the array is allow to be.

sum

$ar->sum;

The sum of all numeric elements in the array.

average

$ar->average;

The average of all numeric elements in the array.

AUTHOR

Gene Boggs <gene@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2015 by Gene Boggs.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.