Package generic.algorithms
Class LCS<T>
- java.lang.Object
-
- generic.algorithms.LCS<T>
-
- Type Parameters:
T
- the type of the objects being compared.
- Direct Known Subclasses:
CodeUnitLCS
public abstract class LCS<T> extends java.lang.Object
Abstract class for finding the LCS between two sequences of Matchable objects.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
LCS()
Convenient constructor for initializing elements in subclasses
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.util.List<T>
getLCS()
java.util.List<T>
getLCS(TaskMonitor monitor)
protected abstract int
lengthOfX()
protected abstract int
lengthOfY()
protected abstract boolean
matches(T x, T y)
protected abstract T
valueOfX(int index)
protected abstract T
valueOfY(int index)
-
-
-
Method Detail
-
lengthOfX
protected abstract int lengthOfX()
- Returns:
- the length of the X sequence.
-
lengthOfY
protected abstract int lengthOfY()
- Returns:
- the length of the Y sequence.
-
valueOfX
protected abstract T valueOfX(int index)
- Parameters:
index
- the position of interest in the X sequence.- Returns:
- the value in the X sequence at
index
. Assumes 1-indexing.
-
valueOfY
protected abstract T valueOfY(int index)
- Parameters:
index
- the position of interest in the Y sequence.- Returns:
- the value in the Y sequence at
index
. Assumes 1-indexing.
-
matches
protected abstract boolean matches(T x, T y)
- Parameters:
x
- the X-sequence element of interesty
- the Y-sequence element of interest- Returns:
- true if
x
matchesy
; false otherwise.
-
getLCS
public java.util.List<T> getLCS()
- Returns:
- a
List<T>
of elements in the LCS.
-
getLCS
public java.util.List<T> getLCS(TaskMonitor monitor) throws CancelledException
- Throws:
CancelledException
-
-