line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Range::Compare::Stream; |
2
|
|
|
|
|
|
|
|
3
|
18
|
|
|
18
|
|
344737
|
use strict; |
|
18
|
|
|
|
|
41
|
|
|
18
|
|
|
|
|
498
|
|
4
|
18
|
|
|
18
|
|
94
|
use warnings; |
|
18
|
|
|
|
|
36
|
|
|
18
|
|
|
|
|
594
|
|
5
|
|
|
|
|
|
|
|
6
|
18
|
|
|
18
|
|
90
|
use base qw(Data::Range::Compare::Stream::Result::Base Data::Range::Compare::Stream::Constants); |
|
18
|
|
|
|
|
33
|
|
|
18
|
|
|
|
|
12252
|
|
7
|
|
|
|
|
|
|
|
8
|
18
|
|
|
18
|
|
95
|
use constant NEW_FROM_CLASS=>'Data::Range::Compare::Stream'; |
|
18
|
|
|
|
|
1181
|
|
|
18
|
|
|
|
|
25553
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION='4.030'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub factory { |
13
|
62384
|
|
|
62384
|
1
|
127451
|
my ($self,@args)=@_; |
14
|
62384
|
|
|
|
|
264828
|
my $new=$self->NEW_FROM_CLASS->new(@args); |
15
|
62384
|
|
|
|
|
175547
|
return $new; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub to_string { |
19
|
53
|
|
|
53
|
1
|
9360
|
my $notation=join ' - ',$_[0]->range_start_to_string,$_[0]->range_end_to_string; |
20
|
53
|
|
|
|
|
153
|
$notation; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
277340
|
|
|
277340
|
1
|
927861
|
sub range_start () { $_[0]->[$_[0]->RANGE_START] } |
24
|
78985
|
|
|
78985
|
1
|
282489
|
sub range_end () { $_[0]->[$_[0]->RANGE_END] } |
25
|
|
|
|
|
|
|
|
26
|
53307
|
|
|
53307
|
1
|
99083
|
sub range_start_to_string () { $_[0]->range_start } |
27
|
53307
|
|
|
53307
|
1
|
103957
|
sub range_end_to_string () { $_[0]->range_end } |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
601
|
0
|
|
sub on_create_range { } |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub add_one ($) { |
32
|
304
|
|
|
304
|
1
|
485
|
my ($self,$value)=@_; |
33
|
304
|
|
|
|
|
953
|
$value + 1; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub sub_one ($) { |
37
|
853
|
|
|
853
|
1
|
1247
|
my ($self,$value)=@_; |
38
|
853
|
|
|
|
|
2564
|
$value - 1; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub cmp_values ($$) { |
42
|
124807
|
|
|
124807
|
1
|
182853
|
my ($self,$value_a,$value_b)=@_; |
43
|
124807
|
|
|
|
|
594403
|
$value_a <=> $value_b |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
329
|
|
|
329
|
1
|
786
|
sub next_range_start () { $_[0]->add_one($_[0]->range_end) } |
47
|
|
|
|
|
|
|
|
48
|
907
|
|
|
907
|
1
|
1921
|
sub previous_range_end () { $_[0]->sub_one($_[0]->range_start) } |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub data { |
51
|
28
|
|
|
28
|
1
|
2367
|
my ($self,$data)=@_; |
52
|
28
|
100
|
|
|
|
163
|
return $self->[$self->RANGE_DATA] unless defined($data); |
53
|
1
|
|
|
|
|
25
|
$self->[$self->RANGE_DATA]=$data; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub get_common_range ($) { |
57
|
1
|
|
|
1
|
1
|
3
|
my ($class,$ranges)=@_; |
58
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
2
|
my ($range_start,$range_end)=@{$ranges}[0,0]; |
|
1
|
|
|
|
|
3
|
|
60
|
|
|
|
|
|
|
|
61
|
1
|
|
|
|
|
6
|
for( my $x=1;$x<=$#$ranges;++$x) { |
62
|
1
|
50
|
|
|
|
4
|
$range_start=$ranges->[$x] if $class->cmp_values($range_start->range_start,$ranges->[$x]->range_start)==-1; |
63
|
1
|
50
|
|
|
|
4
|
$range_end=$ranges->[$x] if $class->cmp_values($range_end->range_end,$ranges->[$x]->range_end)==1; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
1
|
|
|
|
|
3
|
my $new_range=$class->factory($range_start->range_start,$range_end->range_end); |
67
|
|
|
|
|
|
|
|
68
|
1
|
|
|
|
|
4
|
$new_range->on_create_range($range_start); |
69
|
|
|
|
|
|
|
|
70
|
1
|
|
|
|
|
3
|
$new_range; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub find_smallest_outer_ranges { |
74
|
287
|
|
|
287
|
1
|
424
|
my ($self,$ref)=@_; |
75
|
287
|
|
|
|
|
442
|
my $start=$ref->[0]; |
76
|
287
|
|
|
|
|
374
|
my $end=$ref->[0]; |
77
|
|
|
|
|
|
|
|
78
|
287
|
|
|
|
|
519
|
foreach my $range (@$ref) { |
79
|
|
|
|
|
|
|
{ |
80
|
623
|
|
|
|
|
1260
|
my $cmp=$start->cmp_range_start($range); |
81
|
623
|
50
|
100
|
|
|
2674
|
if($cmp==1) { |
|
|
100
|
|
|
|
|
|
82
|
0
|
|
|
|
|
0
|
$start=$range; |
83
|
|
|
|
|
|
|
} elsif($cmp==0 && $start->cmp_range_end($range)==1) { |
84
|
6
|
|
|
|
|
34
|
$start=$range; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
{ |
88
|
623
|
|
|
|
|
730
|
my $cmp=$end->cmp_range_end($range); |
|
623
|
|
|
|
|
905
|
|
|
623
|
|
|
|
|
1186
|
|
89
|
623
|
100
|
100
|
|
|
2447
|
if($cmp==-1) { |
|
|
100
|
|
|
|
|
|
90
|
55
|
|
|
|
|
108
|
$end=$range; |
91
|
|
|
|
|
|
|
} elsif($cmp==0 && $end->cmp_range_start($range)==-1) { |
92
|
1
|
|
|
|
|
3
|
$end=$range; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
} |
96
|
287
|
|
|
|
|
989
|
return ($start,$end); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub get_overlapping_range ($) { |
100
|
127
|
|
|
127
|
1
|
208
|
my ($class,$ranges)=@_; |
101
|
|
|
|
|
|
|
|
102
|
127
|
|
|
|
|
187
|
my ($range_start,$range_end)=@{$ranges}[0,0]; |
|
127
|
|
|
|
|
256
|
|
103
|
|
|
|
|
|
|
|
104
|
127
|
|
|
|
|
379
|
for( my $x=1;$x<=$#$ranges;++$x) { |
105
|
128
|
50
|
|
|
|
315
|
$range_start=$ranges->[$x] if $class->cmp_values($range_start->range_start,$ranges->[$x]->range_start)==1; |
106
|
128
|
100
|
|
|
|
311
|
$range_end=$ranges->[$x] if $class->cmp_values($range_end->range_end,$ranges->[$x]->range_end)==-1; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
127
|
|
|
|
|
288
|
my $new_range=$class->factory($range_start->range_start,$range_end->range_end); |
110
|
127
|
|
|
|
|
327
|
$new_range->on_create_range($range_start); |
111
|
127
|
|
|
|
|
378
|
$new_range; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub cmp_range_start($) { |
116
|
108464
|
|
|
108464
|
1
|
142758
|
my ($self,$cmp)=@_; |
117
|
108464
|
|
|
|
|
195336
|
$self->cmp_values($self->range_start,$cmp->range_start) |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub cmp_range_end($) { |
121
|
10392
|
|
|
10392
|
1
|
14384
|
my ($self,$cmp)=@_; |
122
|
10392
|
|
|
|
|
20851
|
$self->cmp_values($self->range_end,$cmp->range_end) |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub cmp_range_start_to_range_end ($) { |
126
|
0
|
|
|
0
|
1
|
0
|
my ($self,$cmp)=@_; |
127
|
0
|
|
|
|
|
0
|
$self->cmp_values($self->range_start,$cmp->range_end) |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub contains_value ($) { |
132
|
3706
|
|
|
3706
|
1
|
5319
|
my ($self,$cmp)=@_; |
133
|
3706
|
100
|
|
|
|
7337
|
return 0 if $self->cmp_values($self->range_start,$cmp)==1; |
134
|
2048
|
100
|
|
|
|
4572
|
return 0 if $self->cmp_values($cmp,$self->range_end)==1; |
135
|
618
|
|
|
|
|
3211
|
1 |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub contiguous_check ($) { |
139
|
24
|
|
|
24
|
1
|
44
|
my ($cmp_a,$cmp_b)=@_; |
140
|
24
|
|
|
|
|
71
|
$cmp_a->cmp_values( |
141
|
|
|
|
|
|
|
$cmp_a->next_range_start |
142
|
|
|
|
|
|
|
,$cmp_b->range_start |
143
|
|
|
|
|
|
|
)==0 |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub cmp_ranges ($) { |
147
|
822
|
|
|
822
|
1
|
1142
|
my ($range_a,$range_b)=@_; |
148
|
822
|
|
|
|
|
1621
|
my $cmp=$range_a->cmp_range_start($range_b); |
149
|
822
|
100
|
|
|
|
1954
|
if($cmp==0) { |
150
|
254
|
|
|
|
|
534
|
return $range_a->cmp_range_end($range_b); |
151
|
|
|
|
|
|
|
} |
152
|
568
|
|
|
|
|
2796
|
return $cmp; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub boolean () { |
156
|
20
|
|
|
20
|
0
|
55
|
my ($self)=@_; |
157
|
20
|
|
|
|
|
54
|
my $start=$self->range_start; |
158
|
20
|
|
|
|
|
50
|
my $end=$self->range_end; |
159
|
20
|
100
|
|
|
|
64
|
return 0 unless defined($start); |
160
|
16
|
100
|
|
|
|
48
|
return 0 unless defined($end); |
161
|
13
|
100
|
|
|
|
39
|
return 0 if $self->cmp_values($start,$end)==1; |
162
|
10
|
|
|
|
|
43
|
1; |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub overlap ($) { |
166
|
1126
|
|
|
1126
|
1
|
1724
|
my ($range_a,$range_b)=@_; |
167
|
|
|
|
|
|
|
|
168
|
1126
|
100
|
|
|
|
2379
|
return 1 if $range_a->contains_value($range_b->range_start); |
169
|
753
|
100
|
|
|
|
1723
|
return 1 if $range_a->contains_value($range_b->range_end); |
170
|
|
|
|
|
|
|
|
171
|
677
|
100
|
|
|
|
1562
|
return 1 if $range_b->contains_value($range_a->range_start); |
172
|
602
|
50
|
|
|
|
1513
|
return 1 if $range_b->contains_value($range_a->range_end); |
173
|
|
|
|
|
|
|
|
174
|
602
|
|
|
|
|
2022
|
return 0 |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
1; |