line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Range::Compare::Stream::Iterator::Consolidate; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
26413
|
use strict; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
213
|
|
4
|
8
|
|
|
8
|
|
43
|
use warnings; |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
233
|
|
5
|
|
|
|
|
|
|
|
6
|
8
|
|
|
8
|
|
38
|
use base qw(Data::Range::Compare::Stream::Iterator::Base); |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
1370
|
|
7
|
8
|
|
|
8
|
|
40
|
use constant RESULT_CLASS=>'Data::Range::Compare::Stream::Iterator::Consolidate::Result'; |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
481
|
|
8
|
8
|
|
|
8
|
|
2287
|
use Data::Range::Compare::Stream::Iterator::Consolidate::Result; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
4022
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
140
|
|
|
140
|
0
|
650
|
my ($class,$iterator,%args)=@_; |
12
|
140
|
|
|
|
|
563
|
my $self=$class->SUPER::new(iterator=>$iterator,%args); |
13
|
140
|
|
|
|
|
429
|
return $self; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub has_next { |
17
|
1637
|
|
|
1637
|
0
|
6407
|
my ($self)=@_; |
18
|
1637
|
100
|
|
|
|
5171
|
return 1 if $self->{iterator}->has_next; |
19
|
1257
|
100
|
|
|
|
4636
|
return 1 if defined($self->{last_range}); |
20
|
934
|
|
|
|
|
3298
|
return undef; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub get_next { |
25
|
251
|
|
|
251
|
1
|
3144
|
my ($self)=@_; |
26
|
|
|
|
|
|
|
|
27
|
251
|
100
|
|
|
|
632
|
unless(defined($self->{last_range})) { |
28
|
99
|
100
|
|
|
|
337
|
return undef unless $self->{iterator}->has_next; |
29
|
96
|
|
|
|
|
381
|
$self->{last_range}=$self->{iterator}->get_next; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
248
|
|
|
|
|
415
|
my $start_range=$self->{last_range}; |
33
|
248
|
50
|
|
|
|
538
|
return undef unless defined($start_range); |
34
|
|
|
|
|
|
|
|
35
|
248
|
|
|
|
|
313
|
my $overlapping_range=$start_range; |
36
|
248
|
|
|
|
|
304
|
my $end_range=$start_range; |
37
|
248
|
|
|
|
|
316
|
my $did_overlap=0; |
38
|
|
|
|
|
|
|
|
39
|
248
|
|
|
|
|
823
|
while($self->{iterator}->has_next) { |
40
|
182
|
|
|
|
|
628
|
my $next_range=$self->{iterator}->get_next; |
41
|
182
|
100
|
|
|
|
704
|
if($overlapping_range->get_common->overlap($next_range->get_common)) { |
42
|
|
|
|
|
|
|
|
43
|
30
|
|
|
|
|
41
|
$did_overlap=1; |
44
|
30
|
|
|
|
|
78
|
my $new_range=$overlapping_range->get_overlapping_range([$overlapping_range->get_common,$next_range->get_common]); |
45
|
30
|
|
|
|
|
101
|
$self->on_consolidate($new_range->get_common,$overlapping_range->get_common,$next_range->get_common); |
46
|
30
|
|
|
|
|
104
|
$overlapping_range=$new_range->get_common; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
30
|
|
|
|
|
78
|
($start_range,$end_range)=$overlapping_range->get_common->find_smallest_outer_ranges([$start_range->get_common,$end_range->get_common,$next_range->get_common]); |
50
|
|
|
|
|
|
|
} else { |
51
|
152
|
|
|
|
|
254
|
$self->{last_range}=$next_range; |
52
|
152
|
|
|
|
|
458
|
my ($start,$end)=$start_range->get_common->find_smallest_outer_ranges([$start_range->get_common,$end_range->get_common]); |
53
|
152
|
|
|
|
|
875
|
return $self->RESULT_CLASS->new($overlapping_range->get_common,$start->get_common,$end->get_common,0,$did_overlap); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
} |
58
|
96
|
|
|
|
|
205
|
$self->{last_range}=undef; |
59
|
96
|
|
|
|
|
315
|
my ($start,$end)=$start_range->get_common->find_smallest_outer_ranges([$start_range->get_common,$end_range->get_common]); |
60
|
96
|
|
|
|
|
474
|
return $self->RESULT_CLASS->new($overlapping_range->get_common,$start->get_common,$end->get_common,0,$did_overlap); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|