line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooseX::Iterator::Array; |
2
|
3
|
|
|
3
|
|
4122
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use MooseX::Iterator::Meta::Iterable; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.11'; |
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:RLB'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
with 'MooseX::Iterator::Role'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has _position => ( is => 'rw', isa => 'Int', default => 0 ); |
12
|
|
|
|
|
|
|
has '_collection' => ( is => 'rw', isa => 'ArrayRef', init_arg => 'collection' ); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub next { |
15
|
|
|
|
|
|
|
my ($self) = @_; |
16
|
|
|
|
|
|
|
my $position = $self->_position; |
17
|
|
|
|
|
|
|
my $next = $self->_collection->[ $position++ ]; |
18
|
|
|
|
|
|
|
$self->_position($position); |
19
|
|
|
|
|
|
|
return $next; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub has_next { |
23
|
|
|
|
|
|
|
my ($self) = @_; |
24
|
|
|
|
|
|
|
my $position = $self->_position; |
25
|
|
|
|
|
|
|
return exists $self->_collection->[ $self->_position ]; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub peek { |
29
|
|
|
|
|
|
|
my ($self) = @_; |
30
|
|
|
|
|
|
|
if ( $self->has_next ) { |
31
|
|
|
|
|
|
|
return $self->_collection->[ $self->_position + 1 ]; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
return; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub reset { |
37
|
|
|
|
|
|
|
my ($self) = @_; |
38
|
|
|
|
|
|
|
$self->_position(0); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
no Moose; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |