GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
LCS(3) User Contributed Perl Documentation LCS(3)

Algorithm::LCS - Fast (XS) implementation of the Longest Common Subsequence (LCS) Algorithm

  use Algorithm::LCS;

  $alg = Algorithm::LCS->new;
  @lcs = $alg->LCS(\@a,\@b);

  $cb = $alg->callback(@b); # closure
  @lcs = $cb->(\@a);        # same result as prior LCS() call

Algorithm::LCS reimplements Algorithm::Diff's core loop in XS, and provides a simple OO interface to it.

Extract from the Algorithm::Diff v1.15 manpage:

  The algorithm is that described in 
  I<A Fast Algorithm for Computing Longest Common Subsequences>,
  CACM, vol.20, no.5, pp.350-353, May 1977, with a few
  minor improvements to improve the speed.

new()
Creates a new object which maintains internal storage areas for the LCS computation. Use one of these per concurrent LCS() call.

line_map(@lines)
Send @lines to a hashref containing elements of the form

       value => [(increasing) list of matching indices]
    
callback(@lines)
Generates a closure capturing the object and line_map hash for @lines. Most useful when computing multiple LCSs against a single file.
LCS(\@a,\@b)
Finds a Longest Common Subsequence, taking two arrayrefs as method arguments. In scalar context the return value is the length of the subsequence. In list context it yields a list of corresponding indices, which are represented by 2-element array refs. See the Algorithm::Diff manpage for more details.

None by design.

Algorithm::Diff

Joe Schaefer, <joe+cpan@sunstarsys.com>

Copyright 2003 by Joe Schaefer

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

2003-08-11 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.