| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Tie::Array::IntSpan; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
79239
|
use 5.018000; |
|
|
1
|
|
|
|
|
13
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
38
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
40
|
|
|
6
|
1
|
|
|
1
|
|
1957
|
use Log::ger; |
|
|
1
|
|
|
|
|
59
|
|
|
|
1
|
|
|
|
|
5
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
|
9
|
|
|
|
|
|
|
our $DATE = '2021-08-29'; # DATE |
|
10
|
|
|
|
|
|
|
our $DIST = 'Tie-Array-IntSpan'; # DIST |
|
11
|
|
|
|
|
|
|
our $VERSION = '0.002'; # VERSION |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub TIEARRAY { |
|
14
|
1
|
|
|
1
|
|
149
|
my ($class, $intspan) = @_; |
|
15
|
|
|
|
|
|
|
|
|
16
|
1
|
|
|
|
|
6
|
log_trace "TIEARRAY(%s, %s)", $class, \@_; |
|
17
|
1
|
|
|
|
|
5
|
bless [$intspan], $class; |
|
18
|
|
|
|
|
|
|
} |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub FETCH { |
|
21
|
50
|
|
|
50
|
|
83
|
my ($this, $index) = @_; |
|
22
|
50
|
|
|
|
|
94
|
my $res = $this->[0]->lookup($index); |
|
23
|
50
|
|
|
|
|
959
|
log_trace "FETCH(%i) = %s", $index, $res; |
|
24
|
50
|
|
|
|
|
181
|
$res; |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub STORE { |
|
28
|
2
|
|
|
2
|
|
2918
|
my ($this, $index, $value) = @_; |
|
29
|
2
|
|
|
|
|
9
|
log_trace "STORE(%i, %s)", $index, $value; |
|
30
|
2
|
|
|
|
|
11
|
$this->[0]->set($index, $value); |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub FETCHSIZE { |
|
34
|
8
|
|
|
8
|
|
1294
|
my ($this) = @_; |
|
35
|
8
|
|
|
|
|
28
|
my @ranges = $this->[0]->get_range_list; |
|
36
|
8
|
50
|
|
|
|
117
|
my $res = !@ranges ? 0 : ($ranges[-1][1] < 0 ? die("FETCHSIZE(): Cannot handle negative range") : $ranges[-1][1]+1); |
|
|
|
100
|
|
|
|
|
|
|
37
|
8
|
|
|
|
|
23
|
log_trace "FETCHSIZE(): %s", $res; |
|
38
|
8
|
|
|
|
|
51
|
$res; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub STORESIZE { |
|
42
|
0
|
|
|
0
|
|
0
|
my ($this, $count) = @_; |
|
43
|
0
|
|
|
|
|
0
|
die "STORESIZE() not implemented"; |
|
44
|
|
|
|
|
|
|
#log_trace "STORESIZE(%i)", $count; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub EXTEND { |
|
48
|
0
|
|
|
0
|
|
0
|
my ($this, $count) = @_; |
|
49
|
0
|
|
|
|
|
0
|
die "STORESIZE() not implemented"; |
|
50
|
|
|
|
|
|
|
#log_trace "EXTEND(%i)", $count; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub EXISTS { |
|
54
|
2
|
|
|
2
|
|
2546
|
my ($this, $key) = @_; # key = index in our case |
|
55
|
2
|
|
|
|
|
8
|
my @ranges = $this->[0]->get_range_list; |
|
56
|
2
|
|
|
|
|
32
|
my $res = ""; |
|
57
|
2
|
100
|
66
|
|
|
5
|
for (@ranges) { if ($key >= $_->[0] && $key <= $_->[1]) { $res=1; last } } |
|
|
5
|
|
|
|
|
33
|
|
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
3
|
|
|
58
|
2
|
|
|
|
|
8
|
log_trace "EXISTS(%i): %s", $key, $res; |
|
59
|
2
|
|
|
|
|
14
|
$res; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub DELETE { |
|
63
|
1
|
|
|
1
|
|
2195
|
my ($this, $key) = @_; # key = index in our case |
|
64
|
1
|
|
|
|
|
5
|
my $res = $this->[0]->lookup($key); |
|
65
|
1
|
|
|
|
|
25
|
$this->[0]->set($key, undef); |
|
66
|
1
|
|
|
|
|
70
|
log_trace "DELETE(%i): %s", $key, $res; |
|
67
|
1
|
|
|
|
|
4
|
$res; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub CLEAR { |
|
71
|
1
|
|
|
1
|
|
2507
|
my $this = shift; |
|
72
|
1
|
|
|
|
|
5
|
log_trace "CLEAR()"; |
|
73
|
1
|
|
|
|
|
6
|
$this->[0]->clear; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub PUSH { |
|
77
|
1
|
|
|
1
|
|
2492
|
my $this = shift; |
|
78
|
1
|
|
|
|
|
5
|
log_trace "PUSH(%s)", \@_; |
|
79
|
1
|
|
|
|
|
4
|
for (@_) { |
|
80
|
2
|
|
|
|
|
33
|
$this->[0]->set($this->FETCHSIZE, $_); |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub POP { |
|
85
|
0
|
|
|
0
|
|
|
my $this = shift; |
|
86
|
0
|
|
|
|
|
|
die "POP() not yet implemented"; |
|
87
|
|
|
|
|
|
|
#log_trace "POP(): %s", $res; |
|
88
|
|
|
|
|
|
|
#$res; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub SHIFT { |
|
92
|
0
|
|
|
0
|
|
|
my $this = shift; |
|
93
|
0
|
|
|
|
|
|
die "SHIFT() not yet implemented"; |
|
94
|
|
|
|
|
|
|
#log_trace "SHIFT(): %s", $res; |
|
95
|
|
|
|
|
|
|
#$res; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub UNSHIFT { |
|
99
|
0
|
|
|
0
|
|
|
my $this = shift; |
|
100
|
0
|
|
|
|
|
|
die "UNSHIFT() not yet implemented"; |
|
101
|
|
|
|
|
|
|
#log_trace "UNSHIFT(%s)", \@_; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub SPLICE { |
|
105
|
0
|
|
|
0
|
|
|
my $this = shift; |
|
106
|
0
|
|
|
|
|
|
my $offset = shift; |
|
107
|
0
|
|
|
|
|
|
my $length = shift; |
|
108
|
0
|
|
|
|
|
|
die "UNSHIFT() not yet implemented"; |
|
109
|
|
|
|
|
|
|
#log_trace "SPLICE(%i, %i, %s): %s", $offset, $length, \@_, \@res; |
|
110
|
|
|
|
|
|
|
#@res; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub UNTIE { |
|
114
|
0
|
|
|
0
|
|
|
my ($this) = @_; |
|
115
|
0
|
|
|
|
|
|
log_trace "UNTIE()"; |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
# DESTROY |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
1; |
|
121
|
|
|
|
|
|
|
# ABSTRACT: Tied-array interface for Array::IntSpan |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
__END__ |