line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Array::Iterator::Circular; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
71580
|
use strict; |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
30
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.130'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
519
|
use Array::Iterator; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
353
|
|
10
|
|
|
|
|
|
|
our @ISA = qw(Array::Iterator); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub _init { |
13
|
1
|
|
|
1
|
|
3
|
my ($self, @args) = @_; |
14
|
1
|
|
|
|
|
6
|
$self->{loop_counter} = 0; |
15
|
1
|
|
|
|
|
6
|
$self->SUPER::_init(@args); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# always return true, since |
19
|
|
|
|
|
|
|
# we just keep looping |
20
|
5
|
|
|
5
|
1
|
14
|
sub has_next { 1 } |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub next { |
23
|
26
|
|
|
26
|
1
|
40
|
my ($self) = @_; |
24
|
26
|
100
|
|
|
|
52
|
unless ($self->_current_index < $self->getLength()) { |
25
|
5
|
|
|
|
|
13
|
$self->_current_index = 0; |
26
|
5
|
|
|
|
|
9
|
$self->{loop_counter}++; |
27
|
|
|
|
|
|
|
} |
28
|
26
|
|
|
|
|
55
|
$self->_iterated = 1; |
29
|
26
|
|
|
|
|
55
|
return $self->_getItem($self->_iteratee(), $self->_current_index++); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# since neither of them will |
33
|
|
|
|
|
|
|
# ever stop dispensing items |
34
|
|
|
|
|
|
|
# they can just be aliases of |
35
|
|
|
|
|
|
|
# one another. |
36
|
|
|
|
|
|
|
*get_next = \&next; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub is_start { |
39
|
1
|
|
|
1
|
1
|
4
|
my ($self) = @_; |
40
|
1
|
|
|
|
|
7
|
return ($self->_current_index() == 0); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
1
|
|
|
1
|
0
|
3385
|
sub isStart { my $self = shift; $self->is_start(@_) } |
|
1
|
|
|
|
|
6
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub is_end { |
46
|
5
|
|
|
5
|
1
|
8
|
my ($self) = @_; |
47
|
5
|
|
|
|
|
11
|
return ($self->_current_index() == $self->getLength()); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
5
|
|
|
5
|
0
|
26
|
sub isEnd { my $self = shift; $self->is_end(@_) } |
|
5
|
|
|
|
|
10
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub get_loop_count { |
53
|
28
|
|
|
28
|
1
|
45
|
my ($self) = @_; |
54
|
28
|
|
|
|
|
55
|
return $self->{loop_counter}; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
28
|
|
|
28
|
0
|
87
|
sub getLoopCount { my $self = shift; $self->get_loop_count(@_) } |
|
28
|
|
|
|
|
60
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
# ABSTRACT: A subclass of Array::Iterator to allow circular iteration |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
__END__ |