NAME
Array::RealSpan - Map real number ranges to labels or objects
VERSION
version 0.0101
SYNOPSIS
use Array::RealSpan;
my $epoch = Array::RealSpan->new;
$epoch->set_range( 0, 0.01, 'Holocene' );
$epoch->set_range( 0.01, 1.81, 'Pliestocene' );
$epoch->set_range( 1.81, 5.32, 'Pliocene' );
$epoch->set_range( 5.32, 23.8, 'Miocene' );
$epoch->set_range( 23.8, 33.7, 'Oligocene' );
$epoch->set_range( 33.7, 55, 'Eocene' );
$epoch->set_range( 55, 65, 'Paleocene' );
my $name = $epoch->lookup(3.14);
my $range = $epoch->get_range('Holocene');
DESCRIPTION
An Array::RealSpan
object maps real number ranges to associated labels or objects.
NAME
Array::RealSpan - Map real number ranges to labels or objects
METHODS
new
$span = Array::RealSpan->new;
Create a new Array::RealSpan
object.
set_range
$span->set_range( $start, $end, $label );
Add a range, from start to end, for a given label or object.
get_range
$range = $span->get_range($label);
Return the range for the given label or object.
lookup
$label = $span->lookup($number);
Look up the label (or object) for the range containing the given number.
This compares each range by considering the number less than or equal to the start and less than the end.
SEE ALSO
See Array::IntSpan for a more featured implementation (but for integer ranges only).
AUTHOR
Gene Boggs <gene@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2016 by Gene Boggs.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.