Class 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
    • Constructor Detail

      • LCS

        protected LCS()
        Convenient constructor for initializing elements in subclasses
    • 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 interest
        y - the Y-sequence element of interest
        Returns:
        true if x matches y; false otherwise.
      • getLCS

        public java.util.List<T> getLCS()
        Returns:
        a List<T> of elements in the LCS.