Class DiffList<T>

Type Parameters:
T - the type of the item in the list
All Implemented Interfaces:
Serializable, Cloneable, Iterable<Diff<T>>, Collection<Diff<T>>, Deque<Diff<T>>, List<Diff<T>>, Queue<Diff<T>>

public class DiffList<T> extends LinkedList<Diff<T>>
A linked list of Diff objects that provides additional methods for operating on the list or reconstituting the original lists.
See Also:
  • Constructor Details

    • DiffList

      public DiffList()
  • Method Details

    • computeFirstList

      public List<T> computeFirstList()
      Compute and return the source text (all equalities and deletions).
      Returns:
      Source text.
    • computeSecondList

      public List<T> computeSecondList()
      Compute and return the destination text (all equalities and insertions).
      Returns:
      Destination text.
    • getLevenshteinDistance

      public int getLevenshteinDistance()
      Compute the Levenshtein distance; the number of inserted, deleted or substituted characters.
      Returns:
      Number of changes.
    • translateIndex

      public int translateIndex(int loc)
      loc is a location in text1, compute and return the equivalent location in text2. e.g. "The cat" vs "The big cat", 1->1, 5->8
      Parameters:
      loc - Location within text1.
      Returns:
      Location within text2.