in reply to Re: OO Algorithm::Diff (finally) released
in thread OO Algorithm::Diff (finally) released

Thanks!

The nature of the algorithm requires that the data end up in arrays. So supporting iterators would just be bolted on to the front. So for the case of file handles, you might as well just use:

my $diff = Algorithm::Diff->new( [<IN1>], [<IN2>] );

as that will be as efficient as possible.

For the case of other iterators, you might as well provide a general "iterate into a list" procedure that has nothing to do with Algorithm::Diff, for example:

sub cvIterToList { my $cvIter = shift( @_ ); my @list; my $item; while( defined( $item= $cvIter->() ) ) { push @list, $item; } return \@list; }
so:
my $diff = Algorithm::Diff->new( cvIterToList($iter), [<IN>] );

But I could certainly add such to A::Diff anyway. What other types of iterators should I support? Perhaps that is enough since other cases can be covered simply enough with something like:

cvIterToList( sub { $obj->Next() } )

- tye        

Replies are listed 'Best First'.
Re^3: OO Algorithm::Diff (finally) released (iterators)
by diotalevi (Canon) on Sep 28, 2004 at 02:41 UTC
    The nature of the algorithm requires that the data end up in arrays. So supporting iterators would just be bolted on to the front.

    Do you really need to have entire list at once or does it operate on a window? Or does this change depending on the characterization of the differences?

Re^3: OO Algorithm::Diff (finally) released (iterators)
by Aristotle (Chancellor) on Sep 28, 2004 at 08:33 UTC

    Maybe it might be worth a look whether Tie::File helps with files?

    Makeshifts last the longest.