| line | stmt | bran | cond | sub | pod | time | code | 
| 1 | 50 |  |  | 50 |  | 609 | use v5.14; | 
|  | 50 |  |  |  |  | 165 |  | 
| 2 | 50 |  |  | 50 |  | 301 | use warnings; | 
|  | 50 |  |  |  |  | 109 |  | 
|  | 50 |  |  |  |  | 2143 |  | 
| 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.032 | 
| 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 |  | 322 | use Types::Standard qw(ArrayRef ConsumerOf); | 
|  | 50 |  |  |  |  | 148 |  | 
|  | 50 |  |  |  |  | 322 |  | 
| 48 | 50 |  |  | 50 |  | 16218 | use namespace::clean; | 
|  | 50 |  |  |  |  | 117 |  | 
|  | 50 |  |  |  |  | 390 |  | 
| 49 | 50 |  |  | 50 |  | 27168 |  | 
|  | 50 |  |  |  |  | 121 |  | 
|  | 50 |  |  |  |  | 363 |  | 
| 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 | 15157 |  | 
| 63 | 377 |  |  |  |  | 712 | while (1) { | 
| 64 |  |  |  |  |  |  | return unless (scalar(@$list)); | 
| 65 | 377 |  |  |  |  | 489 | my $iter	= $list->[0]; | 
| 66 | 519 | 100 |  |  |  | 1075 | my $item	= $iter->next; | 
| 67 | 392 |  |  |  |  | 552 | unless (defined($item)) { | 
| 68 | 392 |  |  |  |  | 844 | shift(@$list); | 
| 69 | 392 | 100 |  |  |  | 827 | next; | 
| 70 | 142 |  |  |  |  | 208 | } | 
| 71 | 142 |  |  |  |  | 1322 | return $item; | 
| 72 |  |  |  |  |  |  | } | 
| 73 | 250 |  |  |  |  | 596 | } | 
| 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 | 48 | return; | 
| 89 | 2 |  |  |  |  | 3 | } | 
| 90 | 2 |  |  |  |  | 4 | } | 
|  | 2 |  |  |  |  | 6 |  | 
| 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 |