line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use Catmandu::Sane; |
3
|
65
|
|
|
65
|
|
364795
|
|
|
65
|
|
|
|
|
139
|
|
|
65
|
|
|
|
|
392
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.2019'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Catmandu::Util qw(check_array_ref); |
7
|
65
|
|
|
65
|
|
457
|
use Role::Tiny::With; |
|
65
|
|
|
|
|
135
|
|
|
65
|
|
|
|
|
2849
|
|
8
|
65
|
|
|
65
|
|
7477
|
use namespace::clean; |
|
65
|
|
|
|
|
4739
|
|
|
65
|
|
|
|
|
2505
|
|
9
|
65
|
|
|
65
|
|
350
|
|
|
65
|
|
|
|
|
139
|
|
|
65
|
|
|
|
|
416
|
|
10
|
|
|
|
|
|
|
with 'Catmandu::Iterable'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
bless check_array_ref($_[1]), $_[0]; |
13
|
|
|
|
|
|
|
} |
14
|
23
|
|
|
23
|
1
|
2441
|
|
15
|
|
|
|
|
|
|
my ($self) = @_; |
16
|
|
|
|
|
|
|
my $i = 0; |
17
|
|
|
|
|
|
|
sub { |
18
|
12
|
|
|
12
|
0
|
24
|
$self->[$i++]; |
19
|
12
|
|
|
|
|
19
|
}; |
20
|
|
|
|
|
|
|
} |
21
|
28
|
|
|
28
|
|
314
|
|
22
|
12
|
|
|
|
|
60
|
[@{$_[0]}]; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
scalar @{$_[0]}; |
26
|
17
|
|
|
17
|
1
|
106
|
} |
|
17
|
|
|
|
|
46
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my ($self, $cb) = @_; |
29
|
|
|
|
|
|
|
$cb->($_) for @$self; |
30
|
2
|
|
|
2
|
1
|
1678
|
$self->count; |
|
2
|
|
|
|
|
6
|
|
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
$_[0]->[0]; |
34
|
1
|
|
|
1
|
1
|
2
|
} |
35
|
1
|
|
|
|
|
5
|
|
36
|
1
|
|
|
|
|
1598
|
1; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=pod |
40
|
1
|
|
|
1
|
1
|
5
|
|
41
|
|
|
|
|
|
|
=head1 NAME |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Catmandu::ArrayIterator - Convert an arrayref to an Iterable object |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 SYNOPSIS |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
use Catmandu::ArrayIterator; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my $it = Catmandu::ArrayIterator->new([{n => 1}, {n => 2}, {n => 3}]); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
$it->each( sub { |
52
|
|
|
|
|
|
|
my $item = $_[0]; |
53
|
|
|
|
|
|
|
# Very complicated routine |
54
|
|
|
|
|
|
|
... |
55
|
|
|
|
|
|
|
}); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
$it->[0]; |
58
|
|
|
|
|
|
|
# => {n => 1} |
59
|
|
|
|
|
|
|
$it->first; |
60
|
|
|
|
|
|
|
# => {n => 1} |
61
|
|
|
|
|
|
|
$it->map(sub { $_[0]->{n} + 1 })->to_array; |
62
|
|
|
|
|
|
|
# => [2, 3, 4] |
63
|
|
|
|
|
|
|
$it->count |
64
|
|
|
|
|
|
|
# => 3 |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 METHODS |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 new($arrayRef) |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Create a new iterator object from $arrayRef. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 to_array |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Return all the items in the Iterator as an ARRAY ref. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 each(\&callback) |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
For each item in the Iterator execute the callback function with the item as first argument. Returns |
79
|
|
|
|
|
|
|
the number of items in the Iterator. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 count |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Return the count of all the items in the Iterator. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 first |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Return the first item from the Iterator. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 SEE ALSO |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
L<Catmandu::Iterable>, L<Catmandu::Iterator> |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |