line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
50
|
|
|
50
|
|
631
|
use v5.14; |
|
50
|
|
|
|
|
156
|
|
2
|
50
|
|
|
50
|
|
260
|
use warnings; |
|
50
|
|
|
|
|
92
|
|
|
50
|
|
|
|
|
2115
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
Attean::IteratorSequence - Iterator implementation backed by zero or more sub-iterators |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 VERSION |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
This document describes Attean::IteratorSequence version 0.033 |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use v5.14; |
15
|
|
|
|
|
|
|
use Attean; |
16
|
|
|
|
|
|
|
my $iter = Attean::IteratorSequence->new(iterators => [$iter1, $iter2]); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
The Attean::IteratorSequence class represents a typed iterator that is backed |
21
|
|
|
|
|
|
|
by zero or more sub-iterators. When iterated over, it will return all the |
22
|
|
|
|
|
|
|
elements of all of its sub-iterators, in order, before returning undef. |
23
|
|
|
|
|
|
|
It conforms to the L<Attean::API::Iterator> role. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
The Attean::IteratorSequence constructor requires two named arguments: |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=over 4 |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=item iterators |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
An array reference containing zero or more L<Attean::API::Iterator> objects. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=item item_type |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
A string representing the type of the items that will be returned from the |
36
|
|
|
|
|
|
|
iterator. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=back |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 METHODS |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=over 4 |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
use Moo; |
47
|
50
|
|
|
50
|
|
309
|
use Types::Standard qw(ArrayRef ConsumerOf); |
|
50
|
|
|
|
|
111
|
|
|
50
|
|
|
|
|
284
|
|
48
|
50
|
|
|
50
|
|
16157
|
use namespace::clean; |
|
50
|
|
|
|
|
122
|
|
|
50
|
|
|
|
|
444
|
|
49
|
50
|
|
|
50
|
|
27079
|
|
|
50
|
|
|
|
|
114
|
|
|
50
|
|
|
|
|
379
|
|
50
|
|
|
|
|
|
|
with 'Attean::API::Iterator'; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
has iterators => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::Iterator']], default => sub { [] }); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=item C<< next >> |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Returns the iterator's next item, or undef upon reaching the end of iteration. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my $self = shift; |
61
|
|
|
|
|
|
|
my $list = $self->iterators; |
62
|
377
|
|
|
377
|
1
|
14857
|
|
63
|
377
|
|
|
|
|
743
|
while (1) { |
64
|
|
|
|
|
|
|
return unless (scalar(@$list)); |
65
|
377
|
|
|
|
|
479
|
my $iter = $list->[0]; |
66
|
519
|
100
|
|
|
|
1071
|
my $item = $iter->next; |
67
|
392
|
|
|
|
|
630
|
unless (defined($item)) { |
68
|
392
|
|
|
|
|
871
|
shift(@$list); |
69
|
392
|
100
|
|
|
|
804
|
next; |
70
|
142
|
|
|
|
|
245
|
} |
71
|
142
|
|
|
|
|
1624
|
return $item; |
72
|
|
|
|
|
|
|
} |
73
|
250
|
|
|
|
|
647
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=item C<< push( $iterator ) >> |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Adds the new C<< $iterator >> to the end of the array of sub-iterators. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
After this call, C<< $iterator >> will be owned by the IteratorSequence, |
80
|
|
|
|
|
|
|
so making any method calls on C<< $iterator >> after this point may produce |
81
|
|
|
|
|
|
|
unexpected results. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
my $self = shift; |
86
|
|
|
|
|
|
|
my $iter = shift; |
87
|
|
|
|
|
|
|
push(@{ $self->iterators }, $iter); |
88
|
2
|
|
|
2
|
1
|
37
|
return; |
89
|
2
|
|
|
|
|
4
|
} |
90
|
2
|
|
|
|
|
3
|
} |
|
2
|
|
|
|
|
5
|
|
91
|
2
|
|
|
|
|
4
|
|
92
|
|
|
|
|
|
|
1; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=back |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 BUGS |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Please report any bugs or feature requests to through the GitHub web interface |
100
|
|
|
|
|
|
|
at L<https://github.com/kasei/attean/issues>. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 SEE ALSO |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 AUTHOR |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Gregory Todd Williams C<< <gwilliams@cpan.org> >> |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 COPYRIGHT |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Copyright (c) 2014--2022 Gregory Todd Williams. |
113
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under |
114
|
|
|
|
|
|
|
the same terms as Perl itself. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=cut |