Data::MultiValued::RangeContainer - container for ranged values
version 0.0.1_4
Please don't use this module directly, use Data::MultiValued::Ranges.
This module implements the storage for ranged data. It's similar to Array::IntSpan, but simpler (and slower).
A range is defined by a pair of numbers, from and to, and it contains Num $x : $min <= $x < $max. undef is treated as "inf" (negative infinity if used as from or at, positive infinity if used as to).
from
to
Num $x : $min <= $x < $max
undef
at
The internal representation of a range is a hash with three keys, from to value.
value
get
my $value = $obj->get({ at => $point });
Retrieves the range that includes the given point. Throws a Data::MultiValued::Exceptions::RangeNotFound exception if no range includes the point.
get_or_create
$obj->get_or_create({ from => $min, to => $max });
Retrieves the range that has the given extremes. If no such range exists, creates a new range, splicing any existing overlapping range, and returns it. Throws Data::MultiValued::Exceptions::BadRange if $min > $max.
$min > $max
clear
$obj->clear({ from => $min, to => $max });
Removes the range that has the given extremes. If no such range exists, splices any existing overlapping range so that $obj->get({at => $point }) for any $min <= $point < $max will die.
$obj->get({at => $point })
$min <= $point < $max
Throws Data::MultiValued::Exceptions::BadRange if $min > $max.
all_ranges
my @ranges = $obj->all_ranges;
Returns all the ranges defined in this object, as a list of 2-elements arrayrefs.
Gianni Ceccarelli <dakkar@thenautilus.net>
This software is copyright (c) 2011 by Net-a-Porter.com.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Data::MultiValued, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::MultiValued
CPAN shell
perl -MCPAN -e shell install Data::MultiValued
For more information on module installation, please visit the detailed CPAN module installation guide.