
package Text::Wigwam::Engine::Common::Stack;

    use strict;
    use warnings;
    our $VERSION = '0.01';

    use Scalar::Util( qw/reftype/ );

sub new {
    my ($class, $stack) = @_;
    $stack = [] unless $stack && reftype $stack eq 'ARRAY';
    return bless $stack, ref($class) || $class;
}

sub push {
    my ($stack, @items) = @_;
    unshift( @$stack, @items );
    return @items;
}

sub pop {
    my ($stack) = @_;
    shift( @$stack );
    return $stack;
}

sub last_in { $_[0]->[0] }

sub size { scalar @{$_[0]} }

1;
