Author image Michael Shipper
and 1 contributors


Data::Range::Compare::Stream::Iterator::Compare::LayerCake - Compare Result Filtering layer


  use Data::Range::Compare::Stream;
  use Data::Range::Compare::Stream::Iterator::Array;
  use Data::Range::Compare::Stream::Iterator::Consolidate;
  use Data::Range::Compare::Stream::Iterator::Compare::LayerCake;

  my $iterator_a=Data::Range::Compare::Stream::Iterator::Array->new(

  # create a new range and add it to the iterator

  my $iterator_b=Data::Range::Compare::Stream::Iterator::Array->new(

  # create a new range and add it to the iterator


  my $consolidate_a=Data::Range::Compare::Stream::Iterator::Consolidate->new($iterator_a);
  my $consolidate_b=Data::Range::Compare::Stream::Iterator::Consolidate->new($iterator_b);

  my $compare=new Data::Range::Compare::Stream::Iterator::Compare::LayerCake;


  while($compare->has_next) {
    # Result objects are instances of: Data::Range::Compare::Stream::Iterator::Compare::Result
    my $result=$compare->get_next;


This module extends Data::Range::Compare::Stream::Iterator::Compare::Asc.

Data::Range::Compare::Stream::Iterator::Compare::LayerCake compares results from Data::Range::Compare::Stream::Iterator::Consolidate in the following order: Consolidation Asc range_start asc,range_end desc

OO Methods

  • my $compare=new Data::Range::Compare::Stream::Iterator::Compare::LayerCake;

  • my $compare=new Data::Range::Compare::Stream::Iterator::Compare::LayerCake(key=>value);

    The constructor takes all the same arguments Data::Range::Compare::Stream::Iterator::Compare::Asc does along with the following optional arguments:

        factory_instance =>$obj
          # defines the object that implements the $obj->factory($start,$end,$data).
          # new ranges are constructed from the factory interfcae.  If a factory interface
          # is not created an instance of Data::Range::Compare::Stream is assumed.
        ignore_empty=>0|1 # default 0
          # when set to true all empty result sets are returned
        ignore_full=>0|1 # default 0
          # when set to true all full result sets are returned
          # Default: undef  
          # When Defined: code_ref is used to filter results, code_ref->($result);
          #   if the code_ref returns false the result is ignored
          #   if the code_ref returns true the result will be used as the next valid result
  • $compare->add_consolidator($iterator);

    An $iterator object must implement one of the following iterator classes: Data::Range::Compare::Stream::Iterator::Consolidate, Data::Range::Compare::Stream::Iterator::Compare::Asc. Result objects from $iterator->has_next must implement one of the following result objects: Data::Range::Compare::Stream::Iterator::Consolidate::Result, Data::Range::Compare::Stream::Iterator::Compare::Result.

  • while($compare->has_next) { do something }

    Returns true when the there are more ranges to consolidate.

  • my $result=$compare->get_next;

    if $compare->has_next returns true Returns a instance of Data::Range::Compare::Stream::Iterator::Compare::Result.

  • my $count=$compare->get_column_count_human_readable;

    Returns a human readable count of the columns in the comparison object.

  • my $count=$compare->get_column_count;

    Returns the last index id of the iterator column counts.

  • my $range=$compare->get_current_row;

    Returns the range object that will be used in the $compare->get_next call

  • my $boolean=$compare->iterators_empty;

    Returns false when all iterator objects in $compare are depleted

  • my $result=$compare->get_next;

    If $compare->has_next returns true Returns an instance of Data::Range::Compare::Stream::Iterator::Compare::Result.







Michael Shipper

Source-Forge Project

As of version 0.001 the Project has been moved to

Data Range Compare


Copyright 2011 Michael Shipper. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.