I have created a module suitable for uploading to CPAN and request
comments on its name. Here is the first part of the documentation of
what is currently called "Set-Gapfillers":
*****
NAME
Set::Gapfillers - Fill in the gaps between integer ranges
SYNOPSIS
use Set::Gapfillers;
$gf = Set::Gapfillers->new(
lower => -12,
upper => 62,
sets => [
[ 1, 17 ], # Note: Use comma, not
[ 25, 42 ], # range operator (..)
[ 44, 50 ],
],
);
$segments_needed_ref = $gf->segments_needed();
$gapfillers_ref = $gf->gapfillers();
$all_segments_ref = $gf->all_segments();
Any of the three preceding output methods can also be called with an
"expand" option:
$segments_needed_ref = $gf->segments_needed( expand => 1 );
DESCRIPTION
This Perl extension provides methods which may be useful in
manipulating sets whose elements are consecutive integers. Suppose that
you are provided with the following non-intersecting, non-overlapping
sets of consecutive integers:
{ 1 .. 17 }
{ 25 .. 42 }
{ 44 .. 50 }
Suppose further that you are provided with the following lower and
upper bounds to a range of consecutive integers:
lower: 12
upper: 62
Provide a set of sets which:
* when joined together, would form a set of consecutive integers
from the lower to the upper bound, inclusive; and
* are derived from:
* the sets provided;
* proper subsets thereof; or
* newly generated sets which fill in the gaps below, in between
or above the provided sets.
*****
Since the module deals exclusively with sets of consecutive integers, I
could also see calling it "Set::Integer::Gapfillers".
Comments?
The full distribution can be obtained at:
http://thenceforward.net/perl/modules/Set-Gapfillers-0.06.tar.gz
Thank you very much.
Jim Keenan