line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bootylicious::Iterator; |
2
|
|
|
|
|
|
|
|
3
|
18
|
|
|
18
|
|
48479
|
use strict; |
|
18
|
|
|
|
|
84
|
|
|
18
|
|
|
|
|
744
|
|
4
|
18
|
|
|
18
|
|
93
|
use warnings; |
|
18
|
|
|
|
|
23
|
|
|
18
|
|
|
|
|
567
|
|
5
|
|
|
|
|
|
|
|
6
|
18
|
|
|
18
|
|
85
|
use base 'Mojo::Base'; |
|
18
|
|
|
|
|
26
|
|
|
18
|
|
|
|
|
10913
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
__PACKAGE__->attr('elements'); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
129
|
|
|
129
|
1
|
4606
|
my $self = shift->SUPER::new(@_); |
12
|
|
|
|
|
|
|
|
13
|
129
|
|
|
|
|
1168
|
$self->rewind; |
14
|
|
|
|
|
|
|
|
15
|
129
|
|
|
|
|
809
|
return $self; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
260
|
|
|
260
|
0
|
1866
|
sub rewind { shift->{index} = 0 } |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub reverse { |
21
|
2
|
|
|
2
|
0
|
6
|
my $self = shift; |
22
|
|
|
|
|
|
|
|
23
|
2
|
|
|
|
|
5
|
$self->{elements} = [reverse @{$self->{elements}}]; |
|
2
|
|
|
|
|
9
|
|
24
|
|
|
|
|
|
|
|
25
|
2
|
|
|
|
|
16
|
return $self; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
272
|
100
|
|
272
|
0
|
21805
|
sub size { scalar @{shift->{elements} || []} } |
|
272
|
|
|
|
|
1882
|
|
29
|
|
|
|
|
|
|
|
30
|
14
|
|
|
14
|
0
|
100
|
sub first { shift->{elements}->[0] } |
31
|
19
|
|
|
19
|
0
|
87
|
sub last { shift->{elements}->[-1] } |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub current { |
34
|
3
|
|
|
3
|
0
|
5
|
my $self = shift; |
35
|
|
|
|
|
|
|
|
36
|
3
|
|
|
|
|
6
|
my $index = $self->{index}; |
37
|
3
|
100
|
|
|
|
10
|
$index-- if $index; |
38
|
|
|
|
|
|
|
|
39
|
3
|
|
|
|
|
16
|
return $self->{elements}->[$index]; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub take_next { |
43
|
9
|
|
|
9
|
0
|
12
|
my $self = shift; |
44
|
|
|
|
|
|
|
|
45
|
9
|
100
|
|
|
|
23
|
return unless $self->has_next; |
46
|
|
|
|
|
|
|
|
47
|
2
|
|
|
|
|
5
|
return $self->{elements}->[$self->{index}]; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub take_prev { |
51
|
9
|
|
|
9
|
0
|
18
|
my $self = shift; |
52
|
|
|
|
|
|
|
|
53
|
9
|
100
|
|
|
|
41
|
return if $self->{index} < 2; |
54
|
|
|
|
|
|
|
|
55
|
2
|
|
|
|
|
6
|
return $self->{elements}->[$self->{index} - 2]; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub has_next { |
59
|
223
|
|
|
223
|
0
|
262
|
my $self = shift; |
60
|
|
|
|
|
|
|
|
61
|
223
|
100
|
|
|
|
580
|
return $self->{index} < $self->size ? 1 : 0; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub has_prev { |
65
|
28
|
|
|
28
|
0
|
39
|
my $self = shift; |
66
|
|
|
|
|
|
|
|
67
|
28
|
100
|
|
|
|
175
|
return $self->{index} > 0 ? 1 : 0; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub next { |
71
|
232
|
|
|
232
|
0
|
21471
|
my $self = shift; |
72
|
232
|
|
|
|
|
289
|
my $length = shift; |
73
|
|
|
|
|
|
|
|
74
|
232
|
100
|
|
|
|
481
|
if (!$length) { |
75
|
214
|
100
|
|
|
|
527
|
return unless $self->has_next; |
76
|
|
|
|
|
|
|
|
77
|
138
|
|
|
|
|
680
|
return $self->{elements}->[$self->{index}++]; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
18
|
|
|
|
|
24
|
my @elements; |
81
|
18
|
|
|
|
|
56
|
while (my $element = $self->next) { |
82
|
24
|
|
|
|
|
34
|
push @elements, $element; |
83
|
|
|
|
|
|
|
|
84
|
24
|
100
|
|
|
|
73
|
last if --$length <= 0; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
18
|
|
|
|
|
63
|
return $self->new(elements => [@elements]); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub prev { |
91
|
38
|
|
|
38
|
0
|
83
|
my $self = shift; |
92
|
38
|
|
|
|
|
46
|
my $length = shift; |
93
|
|
|
|
|
|
|
|
94
|
38
|
100
|
|
|
|
104
|
if (!$length) { |
95
|
28
|
100
|
|
|
|
88
|
return unless $self->has_prev; |
96
|
|
|
|
|
|
|
|
97
|
8
|
|
|
|
|
30
|
return $self->{elements}->[--$self->{index}]; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
10
|
100
|
|
|
|
49
|
return $self->new(elements => []) if $self->{index} == 0; |
101
|
|
|
|
|
|
|
|
102
|
7
|
|
|
|
|
16
|
$self->{index}--; |
103
|
|
|
|
|
|
|
|
104
|
7
|
|
|
|
|
12
|
my @elements; |
105
|
7
|
|
|
|
|
29
|
while (my $element = $self->prev) { |
106
|
7
|
|
|
|
|
8
|
push @elements, $element; |
107
|
|
|
|
|
|
|
|
108
|
7
|
100
|
|
|
|
24
|
last if --$length <= 0; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
7
|
|
|
|
|
35
|
return $self->new(elements => [@elements]); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
1; |