line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Array::AsHash::Iterator; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
48
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
282
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# my $iterator = Array::AsHash->new({array => \@array})->each; |
9
|
|
|
|
|
|
|
sub new { |
10
|
3
|
|
|
3
|
1
|
6
|
my $class = shift; |
11
|
3
|
|
|
|
|
10
|
my $self = $class->_initialize(@_); |
12
|
3
|
|
|
|
|
13
|
return $self; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub _initialize { |
16
|
3
|
|
|
3
|
|
6
|
my ( $class, $arg_for ) = @_; |
17
|
3
|
|
|
|
|
20
|
my $self = bless { |
18
|
|
|
|
|
|
|
parent_of => $arg_for->{parent}, |
19
|
|
|
|
|
|
|
iterator_for => $arg_for->{iterator}, |
20
|
|
|
|
|
|
|
} => $class; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub next { |
24
|
9
|
|
|
9
|
1
|
1121
|
my $self = shift; |
25
|
9
|
|
|
|
|
30
|
return $self->{iterator_for}->(); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub first { |
29
|
3
|
|
|
3
|
1
|
22
|
my $self = shift; |
30
|
3
|
|
|
|
|
8
|
return $self->parent->first; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub last { |
34
|
3
|
|
|
3
|
1
|
4571
|
my $self = shift; |
35
|
3
|
|
|
|
|
12
|
return $self->parent->last; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub reset_each { |
39
|
1
|
|
|
1
|
1
|
1398
|
my $self = shift; |
40
|
1
|
|
|
|
|
4
|
return $self->parent->reset_each; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub parent { |
44
|
8
|
|
|
8
|
1
|
742
|
my $self = shift; |
45
|
8
|
|
|
|
|
37
|
return $self->{parent_of}; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
__END__ |