Class ReducingListBasedLcs<T>

java.lang.Object
generic.algorithms.Lcs<T>
generic.algorithms.ReducingLcs<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<List<T>,T>
An implementation of the ReducingLcs that takes as its input a list of <T>items, where the list is the 'sequence' being checked for the Longest Common Subsequence.
  • Constructor Details

    • ReducingListBasedLcs

      public ReducingListBasedLcs(List<T> x, List<T> y)
  • Method Details

    • 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 class ReducingLcs<List<T>,T>
      Parameters:
      x - the x-sequence element of interest
      y - the y-sequence element of interest
      Returns:
      true if x matches y; false otherwise
    • reduce

      protected List<T> reduce(List<T> i, int start, int end)
      Description copied from class: ReducingLcs
      Create a subsequence from the given input sequence.
      Specified by:
      reduce in class ReducingLcs<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(List<T> i)
      Description copied from class: ReducingLcs
      Return the length of the given sequence
      Specified by:
      lengthOf in class ReducingLcs<List<T>,T>
      Parameters:
      i - the input sequence (x or y)
      Returns:
      the length
    • valueOf

      protected T valueOf(List<T> i, int offset)
      Description copied from class: ReducingLcs
      Return the value at the given 0-based offset
      Specified by:
      valueOf in class ReducingLcs<List<T>,T>
      Parameters:
      i - the input sequence (x or y)
      offset - the offset
      Returns:
      the value