| 1 | package Data::Range::Compare::Stream::Iterator::Consolidate::AdjacentAsc; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | 3 | ▶ | use base qw(Data::Range::Compare::Stream::Iterator::Consolidate); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | |||||||||||||||
| 7 | |||||||||||||||
| 8 | 28 | ▶ | sub has_next { | ||||||||||||
|
Subroutine
has_next: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||
| 9 | 28 | my ($self)=@_; | |||||||||||||
| 10 | 28 | ▶ | return 1 if $self->SUPER::has_next; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 11 | 9 | ▶ | return 1 if defined($self->{last_result}); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 12 | 7 | return 0; | |||||||||||||
| 13 | } | ||||||||||||||
| 14 | |||||||||||||||
| 15 | 8 | ▶ | sub get_next { | ||||||||||||
|
Subroutine
get_next: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||
| 16 | 8 | my ($self)=@_; | |||||||||||||
| 17 | 8 | ▶ | return undef unless $self->has_next; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 18 | |||||||||||||||
| 19 | 7 | my $result; | |||||||||||||
| 20 | 7 | ▶ | if(defined($self->{last_result})) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 21 | 3 | $result=$self->{last_result}; | |||||||||||||
| 22 | } elsif($self->SUPER::has_next) { | ||||||||||||||
| 23 | 4 | $result=$self->SUPER::get_next; | |||||||||||||
| 24 | } | ||||||||||||||
| 25 | |||||||||||||||
| 26 | 7 | ▶ | while($self->has_next) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 27 | 12 | my $last_result; | |||||||||||||
| 28 | 12 | ▶ | if($self->SUPER::has_next) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 29 | 11 | $last_result=$self->SUPER::get_next; | |||||||||||||
| 30 | } else { | ||||||||||||||
| 31 | 1 | $self->{last_result}=undef; | |||||||||||||
| 32 | 1 | return $result; | |||||||||||||
| 33 | } | ||||||||||||||
| 34 | |||||||||||||||
| 35 | |||||||||||||||
| 36 | # get our common result range | ||||||||||||||
| 37 | 11 | my $common=$result->get_common; | |||||||||||||
| 38 | 11 | my $next=$last_result->get_common; | |||||||||||||
| 39 | |||||||||||||||
| 40 | # stop here if the contiguous check turns up nothing | ||||||||||||||
| 41 | |||||||||||||||
| 42 | 11 | ▶ | unless($common->contiguous_check($next)) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 43 | 3 | $self->{last_result}=$last_result; | |||||||||||||
| 44 | 3 | return $result | |||||||||||||
| 45 | } | ||||||||||||||
| 46 | |||||||||||||||
| 47 | # if we got here then we need to get the starting range | ||||||||||||||
| 48 | |||||||||||||||
| 49 | # compute the overlap | ||||||||||||||
| 50 | 8 | my $overlap=$common->get_overlapping_range([$common,$next]); | |||||||||||||
| 51 | 8 | $self->on_consolidate($overlap,$common,$next); | |||||||||||||
| 52 | |||||||||||||||
| 53 | 8 | my ($start,$end)=$common->find_smallest_outer_ranges([$result->get_start->get_common,$result->get_end->get_common,$last_result->get_start->get_common,$last_result->get_end->get_common]); | |||||||||||||
| 54 | |||||||||||||||
| 55 | # get our new result | ||||||||||||||
| 56 | 8 | $result=$self->RESULT_CLASS->new($overlap,$start->get_common,$end->get_common,0,1); | |||||||||||||
| 57 | |||||||||||||||
| 58 | # update the internals | ||||||||||||||
| 59 | 8 | $self->{last_result}=undef; | |||||||||||||
| 60 | |||||||||||||||
| 61 | |||||||||||||||
| 62 | } | ||||||||||||||
| 63 | |||||||||||||||
| 64 | 3 | $self->{last_result}=undef; | |||||||||||||
| 65 | 3 | return $result; | |||||||||||||
| 66 | } | ||||||||||||||
| 67 | |||||||||||||||
| 68 | 3 | 1; | |||||||||||||