| 1 | package Data::Range::Compare::Stream::Iterator::Consolidate::FillMissing; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | |||||||||||||||
| 6 | 2 | ▶ | use base qw(Data::Range::Compare::Stream::Iterator::Base); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | 2 | ▶ | use Data::Range::Compare::Stream::Iterator::Consolidate::Result; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 8 | 2 | ▶ | use Carp qw(croak); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 9 | |||||||||||||||
| 10 | 2 | ▶ | use constant NEW_RESULT_FROM=>'Data::Range::Compare::Stream::Iterator::Consolidate::Result'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 11 | |||||||||||||||
| 12 | 5 | ▶ | sub new { | ||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||
| 13 | 5 | my ($class,$con,%args)=@_; | |||||||||||||
| 14 | 5 | ▶ | croak 'Consolidator object must be defined' unless defined($con); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 15 | |||||||||||||||
| 16 | 5 | $class->SUPER::new(con=>$con,%args); | |||||||||||||
| 17 | } | ||||||||||||||
| 18 | |||||||||||||||
| 19 | 51 | ▶ | sub has_next { | ||||||||||||
|
Subroutine
has_next: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||
| 20 | 51 | my ($self)=@_; | |||||||||||||
| 21 | 51 | ▶ | return 1 if $self->{con}->has_next; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 22 | 25 | ▶ | return 1 if defined($self->{missing_result}); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 23 | 18 | ▶ | return 1 if defined($self->{last_result_obj}); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 24 | 11 | return 0; | |||||||||||||
| 25 | } | ||||||||||||||
| 26 | |||||||||||||||
| 27 | 24 | ▶ | sub get_next { | ||||||||||||
|
Subroutine
get_next: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||
| 28 | 24 | my ($self)=@_; | |||||||||||||
| 29 | 24 | my $it=$self->{con}; | |||||||||||||
| 30 | |||||||||||||||
| 31 | 24 | my $last_result; | |||||||||||||
| 32 | 24 | ▶ | if(defined($self->{missing_result})) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 33 | 8 | my $result=$self->{missing_result}; | |||||||||||||
| 34 | 8 | $self->{missing_result}=undef; | |||||||||||||
| 35 | 8 | return $result; | |||||||||||||
| 36 | } elsif(defined($self->{last_result_obj})) { | ||||||||||||||
| 37 | 11 | $last_result=$self->{last_result_obj}; | |||||||||||||
| 38 | 11 | $self->{last_result_obj}=undef; | |||||||||||||
| 39 | } else { | ||||||||||||||
| 40 | 5 | ▶ | if($it->has_next) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 41 | 5 | $last_result=$it->get_next; | |||||||||||||
| 42 | } else { | ||||||||||||||
| 43 | 0 | croak 'iterator called when has_next is false!'; | |||||||||||||
| 44 | } | ||||||||||||||
| 45 | } | ||||||||||||||
| 46 | |||||||||||||||
| 47 | 16 | ▶ | if($it->has_next) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 48 | 11 | my $result=$it->get_next; | |||||||||||||
| 49 | 11 | ▶ | if($last_result->get_common->contiguous_check($result->get_common)) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 50 | 3 | $self->{last_result_obj}=$result; | |||||||||||||
| 51 | 3 | return $last_result; | |||||||||||||
| 52 | } else { | ||||||||||||||
| 53 | 8 | $self->{last_result_obj}=$result; | |||||||||||||
| 54 | 8 | my $new_result=$self->create_from_factory($last_result->get_common->next_range_start,$result->get_common->previous_range_end); | |||||||||||||
| 55 | 8 | $new_result->get_common->on_create_range($last_result->get_common); | |||||||||||||
| 56 | 8 | $self->{missing_result}=$self->NEW_RESULT_FROM->new($new_result,$new_result,$new_result,1,1); | |||||||||||||
| 57 | |||||||||||||||
| 58 | 8 | return $last_result; | |||||||||||||
| 59 | } | ||||||||||||||
| 60 | } else { | ||||||||||||||
| 61 | 5 | return $last_result; | |||||||||||||
| 62 | } | ||||||||||||||
| 63 | } | ||||||||||||||
| 64 | |||||||||||||||
| 65 | |||||||||||||||
| 66 | 2 | 1; | |||||||||||||