| 1 | package Number::RangeTracker; | ||||||||||||||||||||||||||||
| 2 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use List::Util 'max'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use List::MoreUtils qw(lastidx lastval); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use Scalar::Util 'looks_like_number'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use Mouse; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | =head1 NAME | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | Number::RangeTracker - Keep track of numerical ranges quickly | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | =head1 VERSION | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | Version 0.6.1 | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | =cut | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 3 | our $VERSION = '0.6.1'; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | Create and modify ranges (three range syntaxes shown): | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | my $range = Number::RangeTracker->new; | ||||||||||||||||||||||||||||
| 27 | $range->add( [ 1, 10 ], '11..20' ); | ||||||||||||||||||||||||||||
| 28 | $range->remove( 6, 15 ); | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | Output ranges, their complement, or integers within ranges | ||||||||||||||||||||||||||||
| 31 | (differences between scalar and list contexts shown): | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | $range->output; | ||||||||||||||||||||||||||||
| 34 | # Scalar context: '1..5,16..20' | ||||||||||||||||||||||||||||
| 35 | # List context: ( 1 => 5, 16 => 20 ) | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | $range->complement; | ||||||||||||||||||||||||||||
| 38 | # Scalar context: '-inf..0,6..15,21..+inf' | ||||||||||||||||||||||||||||
| 39 | # List context: ( -inf => 0, 6 => 15, 21 => +inf ) | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | $range->integers; | ||||||||||||||||||||||||||||
| 42 | # Scalar context: '1,2,3,4,5,16,17,18,19,20' | ||||||||||||||||||||||||||||
| 43 | # List context: ( 1, 2, 3, 4, 5, 16, 17, 18, 19, 20 ) | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | Examine range characteristics: | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | $range->length; # 8 | ||||||||||||||||||||||||||||
| 48 | $range->size; # 10 | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | $range->is_in_range(100); # 0 | ||||||||||||||||||||||||||||
| 51 | $range->is_in_range(18); # 1, 16, 20 | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | An instance of the Number::RangeTracker class is used to keep track of | ||||||||||||||||||||||||||||
| 56 | a set of numerical ranges. Ranges can be added to and removed from | ||||||||||||||||||||||||||||
| 57 | this collection of ranges. Overlapping ranges are collapsed to form a | ||||||||||||||||||||||||||||
| 58 | single, longer range. Ranges can be manipulated, examined, and output | ||||||||||||||||||||||||||||
| 59 | in a variety of ways. | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | While some other modules associate values with a range of keys (see | ||||||||||||||||||||||||||||
| 62 | L</SEE ALSO>), the objective of Number::RangeTracker is to quickly and | ||||||||||||||||||||||||||||
| 63 | easily monitor the integers on a number line that are covered by at | ||||||||||||||||||||||||||||
| 64 | least one range. Number::RangeTracker performs significantly faster | ||||||||||||||||||||||||||||
| 65 | than other modules that have similar functions (see L</SEE ALSO>). | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | =over 4 | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | =item new | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | Initializes a new Number::RangeTracker object. | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | =cut | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 40 | ▶ | has '_added' => ( is => 'rw', isa => 'HashRef', default => sub { {} } ); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 76 | 40 | ▶ | has '_removed' => ( is => 'rw', isa => 'HashRef', default => sub { {} } ); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 77 | 3 | has '_messy_add' => ( is => 'rw', isa => 'Bool', default => 0 ); | |||||||||||||||||||||||||||
| 78 | 3 | has '_messy_rem' => ( is => 'rw', isa => 'Bool', default => 0 ); | |||||||||||||||||||||||||||
| 79 | 3 | has 'units' => ( is => 'ro', isa => 'Num', default => 1 ); | |||||||||||||||||||||||||||
| 80 | 3 | has 'start' => ( is => 'rw', isa => 'Num' ); | |||||||||||||||||||||||||||
| 81 | 3 | has 'end' => ( is => 'rw', isa => 'Num' ); | |||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | =item add( START, END ) | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | Add one or more ranges. This can be used multiple times to add ranges | ||||||||||||||||||||||||||||
| 86 | to the object. Ranges can be added in several ways. The following are | ||||||||||||||||||||||||||||
| 87 | equivalent. | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | $range->add( [ 1, 10 ], [ 16, 20 ] ); | ||||||||||||||||||||||||||||
| 90 | $range->add( 1, 10, 16, 20 ); | ||||||||||||||||||||||||||||
| 91 | $range->add( '1..10', '16..20' ); | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | =cut | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 72 | ▶ | sub add { | ||||||||||||||||||||||||||
|
Subroutine
add: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 96 | 72 | my $self = shift; | |||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 72 | my $ranges = _get_range_inputs(@_); | |||||||||||||||||||||||||||
| 99 | 72 | ▶ | while ( scalar @$ranges ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 100 | 254 | my ( $start, $end ) = splice @$ranges, 0, 2; | |||||||||||||||||||||||||||
| 101 | 254 | $self->_update_range( $start, $end, '_added' ); | |||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 93 | ▶ | sub _get_range_inputs { | ||||||||||||||||||||||||||
|
Subroutine
_get_range_inputs: called CC=5 SCAR=17.8
| |||||||||||||||||||||||||||||
| 106 | 93 | my @range_input = @_; | |||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 93 | my @ranges; | |||||||||||||||||||||||||||
| 109 | 93 | for (@range_input) { | |||||||||||||||||||||||||||
| 110 | 568 | ▶ | if ( ref $_ eq "ARRAY" ) { # [ 1, 10 ], [ 16, 20 ] | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 111 | 0 | push @ranges, @$_; | |||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | elsif (/^\d+\.\.\d+$/) { # '1..10', '16..20' | ||||||||||||||||||||||||||||
| 114 | 0 | push @ranges, split /\.\./; | |||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||
| 116 | else { # 1, 10, 16, 20 | ||||||||||||||||||||||||||||
| 117 | 568 | push @ranges, $_; | |||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 93 | ▶ | croak "Odd number of elements in input ranges (start/stop pairs expected)" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 122 | if scalar @ranges % 2 != 0; | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 93 | return \@ranges; | |||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | =item remove( START, END ) | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | Remove one or more ranges from the current set of ranges. This can be | ||||||||||||||||||||||||||||
| 130 | used multiple times to remove ranges from the object. Ranges can be | ||||||||||||||||||||||||||||
| 131 | removed with the same syntax used for adding ranges. | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | =cut | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | 21 | ▶ | sub remove { | ||||||||||||||||||||||||||
|
Subroutine
remove: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 136 | 21 | my $self = shift; | |||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | 21 | my $ranges = _get_range_inputs(@_); | |||||||||||||||||||||||||||
| 139 | 21 | ▶ | while ( scalar @$ranges ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 140 | 30 | my ( $start, $end ) = splice @$ranges, 0, 2; | |||||||||||||||||||||||||||
| 141 | 30 | $self->_update_range( $start, $end, '_removed' ); | |||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | 284 | ▶ | sub _update_range { | ||||||||||||||||||||||||||
|
Subroutine
_update_range: called CC=8 SCAR=21.9
| |||||||||||||||||||||||||||||
| 146 | 284 | my $self = shift; | |||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | 284 | my ( $start, $end, $add_or_rem ) = @_; | |||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 284 | ▶ | $self->collapse | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->_messy_rem and $add_or_rem eq "_added"
MC/DC100%2/2
$self->_messy_rem and $add_or_rem eq "_added"
$self->_messy_rem
$add_or_rem eq "_added"
Truth table100%3/3
A and B
A= $self->_messy_remB= $add_or_rem eq "_added"
| |||||||||||||||||||||||||||||
| 151 | if $self->_messy_rem && $add_or_rem eq '_added'; | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | 284 | ▶ | croak "'$start' not a number in range '$start to $end'" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 154 | unless looks_like_number $start; | ||||||||||||||||||||||||||||
| 155 | 284 | ▶ | croak "'$end' not a number in range '$start to $end'" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 156 | unless looks_like_number $end; | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | 284 | ▶ | if ( $start > $end ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 159 | 0 | carp | |||||||||||||||||||||||||||
| 160 | "Warning: Range start ($start) is greater than range end ($end); values have been swapped"; | ||||||||||||||||||||||||||||
| 161 | 0 | ( $start, $end ) = ( $end, $start ); | |||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 284 | ▶ | if ( exists $self->{$add_or_rem}{$start} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 165 | $self->{$add_or_rem}{$start} | ||||||||||||||||||||||||||||
| 166 | 0 | = max( $end, $self->{$add_or_rem}{$start} ); | |||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||
| 168 | else { | ||||||||||||||||||||||||||||
| 169 | 284 | $self->{$add_or_rem}{$start} = $end; | |||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 284 | ▶ | if ( $add_or_rem eq '_added' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 173 | 254 | $self->_messy_add(1); | |||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | else { | ||||||||||||||||||||||||||||
| 176 | 30 | $self->_messy_rem(1); | |||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | =item collapse | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | When ranges are added or removed, overlapping ranges are not collapsed | ||||||||||||||||||||||||||||
| 183 | until necessary. This allows range Number::RangeTracker to be very | ||||||||||||||||||||||||||||
| 184 | fast. | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | Ranges can be manually collapsed to avoid memory issues when | ||||||||||||||||||||||||||||
| 187 | working with very large amounts of ranges. In one test, a million | ||||||||||||||||||||||||||||
| 188 | overlapping ranges required ~100 MB of memory. This requirement was | ||||||||||||||||||||||||||||
| 189 | cut drastically by collapsing ranges after every 100,000th range was | ||||||||||||||||||||||||||||
| 190 | added. | ||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | Ranges are automatically collapsed (and merged or removed where | ||||||||||||||||||||||||||||
| 193 | appropriate) (1) before ranges are added (if there are ranges still | ||||||||||||||||||||||||||||
| 194 | waiting to be removed) and (2) before each of the following methods is | ||||||||||||||||||||||||||||
| 195 | executed. | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | =cut | ||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | 88 | ▶ | sub collapse { | ||||||||||||||||||||||||||
|
Subroutine
collapse: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 200 | 88 | my $self = shift; | |||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | 88 | ▶ | return unless $self->_messy_add || $self->_messy_rem; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->_messy_add or $self->_messy_rem
MC/DC100%2/2
$self->_messy_add or $self->_messy_rem
$self->_messy_add
$self->_messy_rem
Truth table100%3/3
A or B
A= $self->_messy_addB= $self->_messy_rem
| |||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | 79 | ▶ | $self->_collapse_ranges('_added') if $self->_messy_add; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | 79 | ▶ | if ( $self->_messy_rem ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 207 | 18 | $self->_collapse_ranges('_removed'); | |||||||||||||||||||||||||||
| 208 | 18 | $self->_remove_ranges; | |||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 79 | $self->_messy_add(0); | |||||||||||||||||||||||||||
| 212 | 79 | $self->_messy_rem(0); | |||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | 82 | ▶ | sub _collapse_ranges { | ||||||||||||||||||||||||||
|
Subroutine
_collapse_ranges: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 216 | 82 | my $self = shift; | |||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | 82 | my $add_or_rem = shift; | |||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | 82 | my @cur_interval; | |||||||||||||||||||||||||||
| 221 | my %temp_ranges; | ||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | 82 | for my $start ( sort { $a <=> $b } keys %{ $self->{$add_or_rem} } ) { | |||||||||||||||||||||||||||
| 224 | 402 | my $end = $self->{$add_or_rem}{$start}; | |||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | 402 | ▶ | unless (@cur_interval) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 227 | 82 | @cur_interval = ( $start, $end ); | |||||||||||||||||||||||||||
| 228 | 82 | next; | |||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | 320 | my ( $cur_start, $cur_end ) = @cur_interval; | |||||||||||||||||||||||||||
| 232 | 320 | ▶ | if ( $start <= $cur_end + 1 ) { # +1 makes it work for integer ranges only | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 233 | 66 | @cur_interval = ( $cur_start, max( $end, $cur_end ) ); | |||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||
| 235 | else { | ||||||||||||||||||||||||||||
| 236 | 254 | $temp_ranges{ $cur_interval[0] } = $cur_interval[1]; | |||||||||||||||||||||||||||
| 237 | 254 | @cur_interval = ( $start, $end ); | |||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||
| 240 | 82 | $temp_ranges{ $cur_interval[0] } = $cur_interval[1]; | |||||||||||||||||||||||||||
| 241 | 82 | $self->{$add_or_rem} = \%temp_ranges; | |||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | 18 | ▶ | sub _remove_ranges { | ||||||||||||||||||||||||||
|
Subroutine
_remove_ranges: called CC=11 SCAR=24.0
| |||||||||||||||||||||||||||||
| 245 | 18 | my $self = shift; | |||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | 18 | my @starts = sort { $a <=> $b } keys %{ $self->_added }; | |||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | 18 | for my $start ( sort { $a <=> $b } keys %{ $self->_removed } ) { | |||||||||||||||||||||||||||
| 250 | 30 | my $end = $self->{_removed}{$start}; | |||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | 30 | ▶ | my $left_start_idx = lastidx { $_ < $start } @starts; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 253 | 30 | ▶ | my $right_start_idx = lastidx { $_ <= $end } @starts; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | 30 | my $left_start = $starts[$left_start_idx]; | |||||||||||||||||||||||||||
| 256 | 30 | my $right_start = $starts[$right_start_idx]; | |||||||||||||||||||||||||||
| 257 | 30 | ▶ | next unless defined $left_start && defined $right_start; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $left_start and defined $right_start
MC/DC0%0/2
defined $left_start and defined $right_start
defined $left_start
defined $right_start
Truth table33%1/3
A and B
A= defined $left_startB= defined $right_start
| |||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | 30 | my $left_end = $self->{_added}{$left_start}; | |||||||||||||||||||||||||||
| 260 | 30 | my $right_end = $self->{_added}{$right_start}; | |||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | # range to remove touches the start of at least one added range | ||||||||||||||||||||||||||||
| 263 | 30 | ▶ | if ( $right_start_idx - $left_start_idx > 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 264 | 11 | delete @{ $self->{_added} } | |||||||||||||||||||||||||||
| 265 | 11 | { @starts[ $left_start_idx + 1 .. $right_start_idx ] }; | |||||||||||||||||||||||||||
| 266 | 11 | ▶ | splice @starts, 0, $right_start_idx + 1 if $right_start_idx > -1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||
| 268 | else { | ||||||||||||||||||||||||||||
| 269 | 19 | ▶ | splice @starts, 0, $left_start_idx + 1 if $left_start_idx > -1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | # range to remove starts inside an added range | ||||||||||||||||||||||||||||
| 273 | 30 | ▶ | if ( $start <= $left_end && $left_start_idx != -1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$start <= $left_end and $left_start_idx != -1
MC/DC100%2/2
$start <= $left_end and $left_start_idx != -1
$start <= $left_end
$left_start_idx != -1
Truth table100%3/3
A and B
A= $start <= $left_endB= $left_start_idx != -1
| |||||||||||||||||||||||||||||
| 274 | 18 | $self->{_added}{$left_start} = $start - 1; | |||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | # range to remove ends inside an added range | ||||||||||||||||||||||||||||
| 278 | 30 | ▶ | if ( $end >= $right_start && $end < $right_end ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$end >= $right_start and $end < $right_end
MC/DC100%2/2
$end >= $right_start and $end < $right_end
$end >= $right_start
$end < $right_end
Truth table100%3/3
A and B
A= $end >= $right_startB= $end < $right_end
| |||||||||||||||||||||||||||||
| 279 | 21 | my $new_start = $end + 1; | |||||||||||||||||||||||||||
| 280 | 21 | $self->{_added}{$new_start} = $right_end; | |||||||||||||||||||||||||||
| 281 | 21 | unshift @starts, $new_start; | |||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | 30 | delete ${ $self->{_removed} }{$start}; | |||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | =item length | ||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||
| 290 | Returns the total length of all ranges combined. | ||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | =cut | ||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | 1 | ▶ | sub length { | ||||||||||||||||||||||||||
|
Subroutine
length: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 295 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | 1 | $self->collapse; | |||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | 1 | my $length = 0; | |||||||||||||||||||||||||||
| 300 | 1 | for ( keys %{ $self->_added } ) { | |||||||||||||||||||||||||||
| 301 | 7 | $length += $self->{_added}{$_} - $_; | |||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||
| 303 | 1 | return $length; | |||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | =item size | ||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||
| 308 | Returns the total number of elements (i.e., integers) of all ranges. | ||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | =cut | ||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | 1 | ▶ | sub size { | ||||||||||||||||||||||||||
|
Subroutine
size: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 313 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||
| 315 | 1 | $self->collapse; | |||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | 1 | my $size = 0; | |||||||||||||||||||||||||||
| 318 | 1 | for ( keys %{ $self->_added } ) { | |||||||||||||||||||||||||||
| 319 | 7 | $size += $self->{_added}{$_} - $_ + 1; # +1 makes it work for integer ranges only | |||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||
| 321 | 1 | return $size; | |||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||
| 324 | =item is_in_range( VALUE ) | ||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | Test whether a VALUE is contained within one of the ranges. Returns 0 | ||||||||||||||||||||||||||||
| 327 | for a negative result. Returns a list of three numbers for a positive | ||||||||||||||||||||||||||||
| 328 | result: 1, start position of the containing range, end position of the | ||||||||||||||||||||||||||||
| 329 | containing range. | ||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | =cut | ||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | 7 | ▶ | sub is_in_range { | ||||||||||||||||||||||||||
|
Subroutine
is_in_range: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 334 | 7 | my $self = shift; | |||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | 7 | my $query = shift; | |||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | 7 | $self->collapse; | |||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||
| 340 | 7 | my @starts = sort { $a <=> $b } keys %{ $self->_added }; | |||||||||||||||||||||||||||
| 341 | 7 | ▶ | my $start = lastval { $_ <= $query } @starts; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||
| 343 | 7 | ▶ | return 0 unless defined $start; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | 6 | my $end = $self->{_added}{$start}; | |||||||||||||||||||||||||||
| 346 | 6 | ▶ | if ( $end < $query ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 347 | 2 | return 0; | |||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||
| 349 | else { | ||||||||||||||||||||||||||||
| 350 | 4 | return ( 1, $start, $end ); | |||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||
| 355 | =item output | ||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||
| 357 | Returns all ranges sorted by their start positions. In list context, | ||||||||||||||||||||||||||||
| 358 | returns a list of all ranges sorted by start positions. This is | ||||||||||||||||||||||||||||
| 359 | suitable for populating a hash, an array, or even another range | ||||||||||||||||||||||||||||
| 360 | object. In scalar context, returns a string of ranges formatted as: | ||||||||||||||||||||||||||||
| 361 | C<1..10,16..20>. | ||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||
| 363 | =cut | ||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||
| 365 | 8 | ▶ | sub output { | ||||||||||||||||||||||||||
|
Subroutine
output: called CC=4 SCAR=14.8
Pod
documented
| |||||||||||||||||||||||||||||
| 366 | 8 | my $self = shift; | |||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||
| 368 | 8 | $self->collapse; | |||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||
| 370 | 8 | ▶ | if ( wantarray() ) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 371 | 5 | return %{ $self->_added }; | |||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||
| 373 | elsif ( defined wantarray() ) { | ||||||||||||||||||||||||||||
| 374 | 12 | return join ',', map {"$_..$self->{_added}{$_}"} | |||||||||||||||||||||||||||
| 375 | 3 | sort { $a <=> $b } keys %{ $self->_added }; | |||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||
| 377 | elsif ( !defined wantarray() ) { | ||||||||||||||||||||||||||||
| 378 | 0 | carp 'Useless use of output() in void context'; | |||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||
| 380 | 0 | else { croak 'Bad context for output()'; } | |||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||
| 383 | =item integers | ||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | Returns each integer contained within the ranges. In list context, | ||||||||||||||||||||||||||||
| 386 | returns a sorted list. In scalar context, returns a sorted, | ||||||||||||||||||||||||||||
| 387 | comma-delimited string of integers. | ||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||
| 389 | =cut | ||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||
| 391 | 2 | ▶ | sub integers { | ||||||||||||||||||||||||||
|
Subroutine
integers: called CC=6 SCAR=19.3
Pod
documented
| |||||||||||||||||||||||||||||
| 392 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||
| 394 | 2 | my @ranges = split ",", $self->output; | |||||||||||||||||||||||||||
| 395 | 2 | my @elements; | |||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||
| 397 | 2 | for (@ranges) { | |||||||||||||||||||||||||||
| 398 | 4 | for my $value ( eval $_ ) { | |||||||||||||||||||||||||||
| 399 | 27 | push @elements, $value; | |||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||
| 403 | 2 | ▶ | if ( wantarray() ) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 404 | 1 | return @elements; | |||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||
| 406 | elsif ( defined wantarray() ) { | ||||||||||||||||||||||||||||
| 407 | 1 | return join ',', @elements; | |||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||
| 409 | elsif ( !defined wantarray() ) { | ||||||||||||||||||||||||||||
| 410 | 0 | carp 'Useless use of output_elements() in void context'; | |||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||
| 412 | 0 | else { croak 'Bad context for output_elements()'; } | |||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||
| 415 | =item complement( UNIVERSE_START, UNIVERSE_END ) | ||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||
| 417 | Returns the complement of a set of ranges. The output is in list | ||||||||||||||||||||||||||||
| 418 | context sorted by range start positions. | ||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||
| 420 | my $original_range = Number::RangeTracker->new; | ||||||||||||||||||||||||||||
| 421 | $original_range->add( [ 11, 20 ], [ 41, 60 ], [ 91, 110 ] ); | ||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||
| 423 | my %complement = $original_range->complement; | ||||||||||||||||||||||||||||
| 424 | # -inf => 10, | ||||||||||||||||||||||||||||
| 425 | # 21 => 40, | ||||||||||||||||||||||||||||
| 426 | # 61 => 90, | ||||||||||||||||||||||||||||
| 427 | # 111 => +inf | ||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||
| 429 | UNIVERSE_START and UNIVERSE_END can be used to specify a finite subset | ||||||||||||||||||||||||||||
| 430 | of the 'universe' of numbers (defaults are -/+ infinity. The | ||||||||||||||||||||||||||||
| 431 | complement ranges are bounded by these values. | ||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||
| 433 | %complement = $original_range->complement( 1, 50 ); | ||||||||||||||||||||||||||||
| 434 | # 1 => 10, | ||||||||||||||||||||||||||||
| 435 | # 21 => 40 | ||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||
| 437 | A new object with the complement of a set of ranges can be created | ||||||||||||||||||||||||||||
| 438 | quickly and easily. | ||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||
| 440 | my $complement_range = Number::RangeTracker->new; | ||||||||||||||||||||||||||||
| 441 | $complement_range->add( $original_range->complement ); | ||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||
| 443 | =cut | ||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||
| 445 | 2 | ▶ | sub complement { | ||||||||||||||||||||||||||
|
Subroutine
complement: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 446 | 2 | my ( $self, $universe_start, $universe_end ) = @_; | |||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||
| 448 | 2 | ▶ | $universe_start = '-inf' unless defined $universe_start; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 449 | 2 | ▶ | $universe_end = '+inf' unless defined $universe_end; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||
| 451 | 2 | my $complement = Number::RangeTracker->new; | |||||||||||||||||||||||||||
| 452 | 2 | $complement->add( $universe_start, $universe_end ); | |||||||||||||||||||||||||||
| 453 | 2 | $complement->remove( $self->output ); | |||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||
| 455 | 2 | return $complement->output; | |||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||
| 458 | =back | ||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||
| 460 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||
| 462 | =over 4 | ||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||
| 464 | =item Monitor the integers covered by at least one range | ||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||
| 466 | Although there is some functional overlap between this module, | ||||||||||||||||||||||||||||
| 467 | L<Number::Range|Number::Range>, and | ||||||||||||||||||||||||||||
| 468 | L<Range::Object::Serial|Range::Object::Serial>, Number::RangeTracker | ||||||||||||||||||||||||||||
| 469 | is significantly faster. | ||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||
| 471 | It takes less than one second for Number::RangeTracker to add 100,000 | ||||||||||||||||||||||||||||
| 472 | overlapping ranges. Over this same period of time, Number::Range and | ||||||||||||||||||||||||||||
| 473 | Range::Serial::Object are only able to add 1,000 and 300 ranges, | ||||||||||||||||||||||||||||
| 474 | respectively. | ||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||
| 476 | Some tasks require even higher throughput. When adding 1 million | ||||||||||||||||||||||||||||
| 477 | overlapping ranges, Number::Range took >250 times as long as | ||||||||||||||||||||||||||||
| 478 | Number::RangeTracker (35 min 31 sec vs. 8 sec). Range::Object::Serial | ||||||||||||||||||||||||||||
| 479 | slows exponentially as ranges are added and, therefore, it was not | ||||||||||||||||||||||||||||
| 480 | feasible to test this many ranges. | ||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||
| 482 | =begin HTML | ||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||
| 484 | <p><img src="https://raw.githubusercontent.com/mfcovington/Number-RangeTracker/master/compare-modules/speed-comparison.png" | ||||||||||||||||||||||||||||
| 485 | width="675" alt="Speed comparison of range modules" /></p> | ||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||
| 487 | =end HTML | ||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||
| 489 | =begin text | ||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||
| 491 | A figure comparing the speed of the three modules is available at: | ||||||||||||||||||||||||||||
| 492 | https://raw.githubusercontent.com/mfcovington/Number-RangeTracker/master/compare-modules/speed-comparison.png | ||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||
| 495 | =end text | ||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||
| 497 | =back | ||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||
| 499 | =begin markdown | ||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||
| 501 |  | ||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||
| 503 | =end markdown | ||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||
| 505 | =over 4 | ||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||
| 507 | =item Ranges with strandedness (like double-stranded DNA or mile posts | ||||||||||||||||||||||||||||
| 508 | on a two-way road) | ||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||
| 510 | L<Bio::Range|Bio::Range> | ||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||
| 512 | =item Compare numbers in an imprecision-tolerant manner | ||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||
| 514 | L<Number::Tolerant|Number::Tolerant> | ||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||
| 516 | =item Named ranges | ||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||
| 518 | L<Tie::RangeHash|Tie::RangeHash>, | ||||||||||||||||||||||||||||
| 519 | L<Array::IntSpan|Array::IntSpan> | ||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||
| 521 | =back | ||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||
| 523 | =head1 SOURCE AVAILABILITY | ||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||
| 525 | The source code is on Github: | ||||||||||||||||||||||||||||
| 526 | L<https://github.com/mfcovington/Number-RangeTracker> | ||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||
| 528 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||
| 530 | Michael F. Covington, <mfcovington@gmail.com> | ||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||
| 532 | =head1 BUGS | ||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||
| 534 | Please report any bugs or feature requests at | ||||||||||||||||||||||||||||
| 535 | L<https://github.com/mfcovington/Number-RangeTracker/issues>. | ||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||
| 537 | =head1 INSTALLATION | ||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||
| 539 | To install this module from GitHub using cpanm: | ||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||
| 541 | cpanm git@github.com:mfcovington/Number-RangeTracker.git | ||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||
| 543 | Alternatively, download and run the following commands: | ||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||
| 545 | perl Build.PL | ||||||||||||||||||||||||||||
| 546 | ./Build | ||||||||||||||||||||||||||||
| 547 | ./Build test | ||||||||||||||||||||||||||||
| 548 | ./Build install | ||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||
| 550 | =head1 SUPPORT AND DOCUMENTATION | ||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||
| 552 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||
| 554 | perldoc Number::RangeTracker | ||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||
| 556 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||
| 558 | Copyright 2014 Michael F. Covington. | ||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||
| 560 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||
| 561 | under the terms of the the Artistic License (2.0). You may obtain a | ||||||||||||||||||||||||||||
| 562 | copy of the full license at: | ||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||
| 564 | L<http://www.perlfoundation.org/artistic_license_2_0> | ||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||
| 566 | Any use, modification, and distribution of the Standard or Modified | ||||||||||||||||||||||||||||
| 567 | Versions is governed by this Artistic License. By using, modifying or | ||||||||||||||||||||||||||||
| 568 | distributing the Package, you accept this license. Do not use, modify, | ||||||||||||||||||||||||||||
| 569 | or distribute the Package, if you do not accept this license. | ||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||
| 571 | If your Modified Version has been derived from a Modified Version made | ||||||||||||||||||||||||||||
| 572 | by someone other than you, you are nevertheless required to ensure that | ||||||||||||||||||||||||||||
| 573 | your Modified Version complies with the requirements of this license. | ||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||
| 575 | This license does not grant you the right to use any trademark, service | ||||||||||||||||||||||||||||
| 576 | mark, tradename, or logo of the Copyright Holder. | ||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||
| 578 | This license includes the non-exclusive, worldwide, free-of-charge | ||||||||||||||||||||||||||||
| 579 | patent license to make, have made, use, offer to sell, sell, import and | ||||||||||||||||||||||||||||
| 580 | otherwise transfer the Package with respect to any patent claims | ||||||||||||||||||||||||||||
| 581 | licensable by the Copyright Holder that are necessarily infringed by the | ||||||||||||||||||||||||||||
| 582 | Package. If you institute patent litigation (including a cross-claim or | ||||||||||||||||||||||||||||
| 583 | counterclaim) against any party alleging that the Package constitutes | ||||||||||||||||||||||||||||
| 584 | direct or contributory patent infringement, then this Artistic License | ||||||||||||||||||||||||||||
| 585 | to you shall terminate on the date that such litigation is filed. | ||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||
| 587 | Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER | ||||||||||||||||||||||||||||
| 588 | AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. | ||||||||||||||||||||||||||||
| 589 | THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||||||||||||||||||||||||||||
| 590 | PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY | ||||||||||||||||||||||||||||
| 591 | YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR | ||||||||||||||||||||||||||||
| 592 | CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR | ||||||||||||||||||||||||||||
| 593 | CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, | ||||||||||||||||||||||||||||
| 594 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||
| 596 | =cut | ||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||
| 598 | 3 | __PACKAGE__->meta->make_immutable(); | |||||||||||||||||||||||||||