line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
3
|
|
|
3
|
|
58364
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
94
|
|
2
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
1353
|
|
3
|
|
|
|
|
|
|
package Array::Sticky; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = 0.01; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub TIEARRAY { |
8
|
3
|
|
|
3
|
|
47
|
my ($class, %args) = @_; |
9
|
|
|
|
|
|
|
|
10
|
3
|
50
|
|
|
|
18
|
my $self = bless +{ |
11
|
3
|
50
|
|
|
|
15
|
head => [ @{ $args{head} || [] } ], |
12
|
3
|
100
|
|
|
|
26
|
body => [ @{ $args{body} || [] } ], |
13
|
3
|
|
|
|
|
6
|
tail => [ @{ $args{tail} || [] } ], |
14
|
|
|
|
|
|
|
}, $class; |
15
|
|
|
|
|
|
|
|
16
|
3
|
|
|
|
|
40
|
return $self; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
3
|
|
|
3
|
|
420
|
sub POP { pop @{shift()->{body}} } |
|
3
|
|
|
|
|
12
|
|
20
|
1
|
|
|
1
|
|
686
|
sub PUSH { push @{shift()->{body}}, @_ } |
|
1
|
|
|
|
|
5
|
|
21
|
3
|
|
|
3
|
|
486
|
sub SHIFT { shift @{shift()->{body}} } |
|
3
|
|
|
|
|
14
|
|
22
|
3
|
|
|
3
|
|
418
|
sub UNSHIFT { unshift @{shift()->{body}}, @_ } |
|
3
|
|
|
|
|
23
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub CLEAR { |
25
|
2
|
|
|
2
|
|
31
|
my ($self) = @_; |
26
|
2
|
|
|
|
|
3
|
@{$self->{body}} = (); |
|
2
|
|
|
|
|
16
|
|
27
|
|
|
|
|
|
|
} |
28
|
2
|
|
|
2
|
|
7
|
sub EXTEND {} |
29
|
|
|
|
|
|
|
sub EXISTS { |
30
|
0
|
|
|
0
|
|
0
|
my ($self, $index) = @_; |
31
|
0
|
|
|
|
|
0
|
my @serial = $self->serial; |
32
|
0
|
|
|
|
|
0
|
return exists $serial[$index]; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub serial { |
36
|
0
|
|
|
0
|
0
|
0
|
my ($self) = @_; |
37
|
0
|
|
|
|
|
0
|
return map { @{$self->{$_}} } qw(head body tail); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub STORE { |
41
|
12
|
|
|
12
|
|
43
|
my ($self, $index, $value) = @_; |
42
|
12
|
|
|
|
|
41
|
$self->{body}[$index] = $value; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub SPLICE { |
46
|
4
|
|
|
4
|
|
1303
|
my $self = shift; |
47
|
4
|
|
100
|
|
|
18
|
my $offset = shift || 0; |
48
|
4
|
50
|
|
|
|
5
|
my $length = shift; $length = $self->FETCHSIZE if ! defined $length; |
|
4
|
|
|
|
|
10
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# avoid "splice() offset past end of array" |
51
|
3
|
|
|
3
|
|
18
|
no warnings; |
|
3
|
|
|
|
|
17
|
|
|
3
|
|
|
|
|
807
|
|
52
|
|
|
|
|
|
|
|
53
|
4
|
|
|
|
|
5
|
return splice @{$self->{body}}, $offset, $length, @_; |
|
4
|
|
|
|
|
21
|
|
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub FETCHSIZE { |
57
|
187
|
|
|
187
|
|
132593
|
my $self = shift; |
58
|
|
|
|
|
|
|
|
59
|
187
|
|
|
|
|
211
|
my $size = 0; |
60
|
187
|
|
|
|
|
372
|
my %size = $self->sizes; |
61
|
|
|
|
|
|
|
|
62
|
187
|
|
|
|
|
480
|
foreach (values %size) { |
63
|
561
|
|
|
|
|
789
|
$size += $_; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
187
|
|
|
|
|
764
|
return $size; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub sizes { |
70
|
400
|
|
|
400
|
0
|
439
|
my $self = shift; |
71
|
400
|
|
|
|
|
512
|
return map { $_ => scalar @{$self->{$_}} } qw(head body tail); |
|
1200
|
|
|
|
|
1167
|
|
|
1200
|
|
|
|
|
3253
|
|
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub FETCH { |
75
|
213
|
|
|
213
|
|
603
|
my $self = shift; |
76
|
213
|
|
|
|
|
249
|
my $index = shift; |
77
|
|
|
|
|
|
|
|
78
|
213
|
|
|
|
|
358
|
my %size = $self->sizes; |
79
|
|
|
|
|
|
|
|
80
|
213
|
|
|
|
|
390
|
foreach my $slot (qw(head body tail)) { |
81
|
422
|
100
|
|
|
|
756
|
if ($size{$slot} > $index) { |
82
|
213
|
|
|
|
|
7011
|
return $self->{$slot}[$index]; |
83
|
|
|
|
|
|
|
} else { |
84
|
209
|
|
|
|
|
877
|
$index -= $size{$slot}; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
return $self->{body}[$size{body} + 1] = undef; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__ |