| HTML-Widgets-NavMenu documentation | Contained in the HTML-Widgets-NavMenu distribution. |
HTML::Widgets::NavMenu::Tree::Iterator::Stack - a simple stack class.
For internal use only.
Pushes an item.
Returns the number of elements.
Returns the highest item.
Returns the item of index $index.
Pops the item and returns it.
Returns true if the stack is empty.
Empties the stack
Copyright 2006 Shlomi Fish, all rights reserved.
This program is released under the following license: MIT X11.
| HTML-Widgets-NavMenu documentation | Contained in the HTML-Widgets-NavMenu distribution. |
package HTML::Widgets::NavMenu::Tree::Iterator::Stack; use strict; use warnings; use base qw(HTML::Widgets::NavMenu::Object); __PACKAGE__->mk_acc_ref([qw(_items)]); sub _init { my $self = shift; $self->reset(); return 0; }
sub push { my $self = shift; my $item = shift; push @{$self->_items()}, $item; return 0; }
sub len { my $self = shift; return scalar(@{$self->_items()}); }
sub top { my $self = shift; return $self->_items->[-1]; }
sub item { my $self = shift; my $index = shift; return $self->_items->[$index]; }
sub pop { my $self = shift; return pop(@{$self->_items()}); }
sub is_empty { my $self = shift; return ($self->len() == 0); }
sub reset { my $self = shift; $self->_items([]); return 0; }
1;