Michael Shipper
and 1 contributors

NAME

Data::Range::Compare::Stream::Iterator::Consolidate - Consolidates overlapping and duplicate ranges

SYNOPSIS

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

  my $iterator=Data::Range::Compare::Stream::Iterator::Array->new(
    new_from=>'Data::Range::Compare::Stream',
  );

  # create a new range and add it to the iterator
  $iterator->create_range(0,0);

  my $range=Data::Range::Compare::Stream->new(0,1);

  # add a new range from the existing one
  $iterator->add_range($range);

  $iterator->prepare_for_consolidate_asc;
  my $processor=Data::Range::Compare::Stream::Iterator::Consolidate->new($iterator);

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

DESCRIPTION

This module extends Data::Range::Compare::Stream::Iterator::Base and implements the consolidation engine for Data::Range::Compare::Stream.

Data::Range::Compare::Stream::Iterator::Consolidate can consolidate ranges sorted in the following order:

Consolidation Asc range_start asc,range_end desc.

OO Methods

  • my $processor=new Data::Range::Compare::Stream::Iterator::Consolidate($iterator);

  • my $processor=new Data::Range::Compare::Stream::Iterator::Consolidate($iterator,factory_instance =>$obj);

    Object constructor has one required argument: $iterator. An $iterator object must extend Data::Range::Compare::Stream::Iterator::Base. Results from the $iterator->get_next call are required to extend or implement Data::Range::Compare::Stream.

    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.
  • while($processor->has_next) { do something }

    Returns true when the there are more ranges to consolidate

  • my $range=$processor->get_next;

    If $processor->has_next returns true Returns a instance of Data::Range::Compare::Stream::Iterator::Consolidate::Result.

  • $self->on_consolidate($new_range,$overlapping_range,$next_range)

    Intended for sub classing: Called when ranges are being consolidated receives 3 arguments along with "$self": 1. $new_range, 2. Overlapping Range 3. The next range returned by $iterator that overlaps with the Overlapping Range.

  • $processor->set_column_id($id);

    Sets the column_id value. This is used by the Compare Layer

  • my $id=$processor->get_column_id($id);

    Gets the column_id, returns undef if not set.

  • my $id=$processor->get_root_column_id;

    Gets the parent object's column_id, returns undef if not set.

  • if($processor->is_child) { ... }

    Returns true if this object is a child of another Consolidaor object.

SEE ALSO

Data::Range::Compare::Stream::Iterator::Consolidate::Result

Data::Range::Compare::Stream::Iterator::Base

Data::Range::Compare::Stream::Cookbook

AUTHOR

Michael Shipper

Source-Forge Project

As of version 0.001 the Project has been moved to Source-Forge.net

Data Range Compare https://sourceforge.net/projects/data-range-comp/

COPYRIGHT

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.