NAME

TB2::Stack - A stack object to be used when you need a stack of things.

SYNOPSIS

# TODO

use TB2::Stack;
my $stack = TB2::Stack->new;

DESCRIPTION

A generic stack object that centralizes the idea of a stack.

Methods

type

This is a read only attribute that is to be specified at creation if you need to have a stack that only contains a specific type of items.

Because this is a stack the value supplied for type is expected to be the subtype for ArrayRef. So, for example, if type => 'Str' then items will be of type ArrayRef[Str], if type => undef then items will just remain of type ArrayRef. Due to the way that the type system works you can only specify the inital value of the item, no complex types can be specified.

Default: undef implying that any item can be contained in the stack.

items

my $items = $stack->items;

Returns an array ref of the TB2::AssertRecord objects on the stack.

count

Returns the count of the items in the stack.

pop

Remove the last element from the items stack and return it.

shift

Remove the first element of the items stack, and return it.

splice

!!!! CURRENTLY NOT IMPLIMENTED AS THERE COULD BE ISSUES WITH THREADS !!!!

Add or remove elements anywhere in an array

unshift

Prepend item(s) to the beginning of the items stack.

push

Append one or more elements to the items stack.