Class ReducingLcs<I,T>
- Type Parameters:
I- The input sequence typeT- the individual element type of the input sequence
- Direct Known Subclasses:
ReducingListBasedLcs
x and y.
This is an optimizing version of the Lcs that will pre-calculate all similar
items from the beginning and end of the two given sequences. Doing this will reduce
the size of the matrix created by the parent class, greatly so in the case that the
two inputs are mostly the same in the beginning and end. (Imagine an edit of a source
code file, where the typical change is somewhere in the middle of the file. In this example,
the optimization performed here can greatly decrease the amount of work to be performed when
calculating the LCS.)
Note: the parent LCS algorithm is bound by Lcs.getSizeLimit(). However, this class
allows clients to work around this restriction when the data has a similar beginning and ending,
as the similar parts will not be counted against the size limit.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoGetLcs(TaskMonitor monitor) Get the actual LCS based upon the already created matrixprotected abstract intReturn the length of the given sequenceprotected intReturns the length of the x sequenceprotected intReturns the length of the y sequenceprotected booleanReturns true if the value of x and y matchprotected abstract ICreate a subsequence from the given input sequence.protected abstract TReturn the value at the given 0-based offsetprotected TvalueOfX(int index) Gets the value of the x sequence at the given index, where index is 1-basedprotected TvalueOfY(int index) Gets the value of the y sequence at the given index, where index is 1-basedMethods inherited from class generic.algorithms.Lcs
getLcs, getLcs, getSizeLimit, setSizeLimit
-
Constructor Details
-
ReducingLcs
Constructor- Parameters:
ix- the input sequencexiy- the input sequencey
-
-
Method Details
-
reduce
Create a subsequence from the given input sequence.- Parameters:
i- the input sequence; 0-based (x or y)start- the start index; 0-based (inclusive)end- the end index (exclusive)- Returns:
- the subsequence
-
lengthOf
Return the length of the given sequence- Parameters:
i- the input sequence (x or y)- Returns:
- the length
-
valueOf
Return the value at the given 0-based offset- Parameters:
i- the input sequence (x or y)offset- the offset- Returns:
- the value
-
doGetLcs
Description copied from class:LcsGet the actual LCS based upon the already created matrix- Overrides:
doGetLcsin classLcs<T>- Parameters:
monitor- the task monitor- Returns:
- the LCS list
- Throws:
CancelledException- if the monitor is cancelled
-
lengthOfX
protected int lengthOfX()Description copied from class:LcsReturns the length of the x sequence -
lengthOfY
protected int lengthOfY()Description copied from class:LcsReturns the length of the y sequence -
valueOfX
Description copied from class:LcsGets the value of the x sequence at the given index, where index is 1-based -
valueOfY
Description copied from class:LcsGets the value of the y sequence at the given index, where index is 1-based -
matches
Description copied from class:LcsReturns true if the value of x and y match
-