Package generic.algorithms
Class ReducingListBasedLcs<T>
- java.lang.Object
-
- generic.algorithms.Lcs<T>
-
- generic.algorithms.ReducingLcs<java.util.List<T>,T>
-
- generic.algorithms.ReducingListBasedLcs<T>
-
- Type Parameters:
T
- the type of the item in the sequence of items
public class ReducingListBasedLcs<T> extends ReducingLcs<java.util.List<T>,T>
An implementation of theReducingLcs
that takes as its input a list ofitems, where the list is the 'sequence' being checked for the Longest Common Subsequence.
-
-
Constructor Summary
Constructors Constructor Description ReducingListBasedLcs(java.util.List<T> x, java.util.List<T> y)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
lengthOf(java.util.List<T> i)
Return the length of the given sequenceprotected boolean
matches(T x, T y)
Returns true if the value of x and y matchprotected java.util.List<T>
reduce(java.util.List<T> i, int start, int end)
Create a subsequence from the given input sequence.protected T
valueOf(java.util.List<T> i, int offset)
Return the value at the given 0-based offset-
Methods inherited from class generic.algorithms.ReducingLcs
doGetLcs, lengthOfX, lengthOfY, valueOfX, valueOfY
-
Methods inherited from class generic.algorithms.Lcs
getLcs, getLcs, getSizeLimit, setSizeLimit
-
-
-
-
Method Detail
-
matches
protected boolean matches(T x, T y)
Description copied from class:Lcs
Returns true if the value of x and y match- Overrides:
matches
in classReducingLcs<java.util.List<T>,T>
- Parameters:
x
- the x-sequence element of interesty
- the y-sequence element of interest- Returns:
- true if
x
matchesy
; false otherwise
-
reduce
protected java.util.List<T> reduce(java.util.List<T> i, int start, int end)
Description copied from class:ReducingLcs
Create a subsequence from the given input sequence.- Specified by:
reduce
in classReducingLcs<java.util.List<T>,T>
- 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
protected int lengthOf(java.util.List<T> i)
Description copied from class:ReducingLcs
Return the length of the given sequence- Specified by:
lengthOf
in classReducingLcs<java.util.List<T>,T>
- Parameters:
i
- the input sequence (x or y)- Returns:
- the length
-
valueOf
protected T valueOf(java.util.List<T> i, int offset)
Description copied from class:ReducingLcs
Return the value at the given 0-based offset- Specified by:
valueOf
in classReducingLcs<java.util.List<T>,T>
- Parameters:
i
- the input sequence (x or y)offset
- the offset- Returns:
- the value
-
-