Set::Integer::Gapfillers

Set::Integer::Gapfillers is a Perl module that can fill in the gaps between integer ranges.
Download

Set::Integer::Gapfillers Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • James E Keenan
  • Publisher web site:
  • http://search.cpan.org/~particle/parrot-0.6.1/lib/Parrot/Pmc2c/Pmc2cMain.pm

Set::Integer::Gapfillers Tags


Set::Integer::Gapfillers Description

Set::Integer::Gapfillers is a Perl module that can fill in the gaps between integer ranges. Set::Integer::Gapfillers is a Perl module that can fill in the gaps between integer ranges.SYNOPSIS use Set::Integer::Gapfillers; $gf = Set::Integer::Gapfillers->new( lower => -12, upper => 62, sets => , # Note: Use comma, not , # range operator (..) , ], ); $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 );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: 62Provide a set of sets which:when joined together, would form a set of consecutive integers from the lower to the upper bound, inclusive; andare derived from: the sets provided;proper subsets thereof; ornewly generated sets which fill in the gaps below, in between or above the provided sets.Once a Set::Integer::Gapfillers object has been constructed, its segments_needed() method can be used to provide these results: { 12 .. 17 } # subset of 1st set provided { 18 .. 24 } # gap-filler set { 25 .. 42 } # 2nd set provided { 43 .. 43 } # gap-filler set # (which happens to consist of a single element) { 44 .. 50 } # 3rd set provided { 51 .. 62 } # gap-filler set for range above highest provided setAlternatively, you may only wish to examine the gap-filler sets. The gapfillers() method provides this set of sets. { 18 .. 24 } # gap-filler set { 43 .. 43 } # gap-filler set { 51 .. 62 } # gap-filler setAnd, as an additional alternative, you may wish to have your set of sets begin or end with all the values of a given provided set, rather than a proper subset thereof containing only those values needed to populate the desired range. In that case, use the all_segments() method. { 1 .. 17 } # 1st set provided { 18 .. 24 } # gap-filler set { 25 .. 42 } # 2nd set provided { 43 .. 43 } # gap-filler set # (which happens to consist of a single element) { 44 .. 50 } # 3rd set provided { 51 .. 62 } # gap-filler set for range above highest provided setThe results returned by the all_segments() method differ from those returned by the segments_needed() method only at the lower or upper ends. If, as in the above example, the lower bound of the target range of integers falls inside a provided segment, the first set returned by all_segments() will be the entire first set provided; the first set returned by segments_needed() will be a proper subset of the first set provided, starting with the requested lower bound. Requirements: · Perl


Set::Integer::Gapfillers Related Software