VTT Java
2010 Version

gov.nih.nlm.nls.vtt.Lib
Class Diff<E>

java.lang.Object
  extended by gov.nih.nlm.nls.vtt.Lib.Diff<E>

public class Diff<E>
extends java.lang.Object

This class implements the Longest Common Subsequences Algorithm to find difference between two lists of objects. This code is modified from Diff.java from incava.org Compares two lists, returning a list of the additions, changes, and deletions between them. A Comparator may be passed as an argument to the constructor, and will thus be used. If not provided, the initial value in the aList ("from") list will be looked at to see if it supports the comparable interface. If so, its equals and compareTo methods will be invoked on the instances in the "from" and "to" lists; otherwise, for speed, hash codes from the objects will be used instead for comparison.

History:

Version:
V-2010
Author:
NLM NLS Development Team, clu

Field Summary
protected  java.util.List<E> aList_
          The source list, AKA the "from" values
protected  java.util.List<E> bList_
          The target list, AKA the "to" values
protected  java.util.List<Difference> diffs_
          The list of differences
 
Constructor Summary
Diff(E[] aArray, E[] bArray)
          Constructs the Diff object by specifying two arrays with the default comparison mechanism between the objects, such as equals and compareTo.
Diff(E[] aArray, E[] bArray, java.util.Comparator<E> comparator)
          Constructs the Diff object by specifying two arrays and comparator.
Diff(java.util.List<E> aList, java.util.List<E> bList)
          Constructs the Diff object by specifying two lists with the default comparison mechanism between the objects, such as equals and compareTo.
Diff(java.util.List<E> aList, java.util.List<E> bList, java.util.Comparator<E> comparator)
          Constructs the Diff object by specifying two lists and comparator.
 
Method Summary
 java.util.List<Difference> GetDiff()
          Runs diff and get the results.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

aList_

protected java.util.List<E> aList_
The source list, AKA the "from" values


bList_

protected java.util.List<E> bList_
The target list, AKA the "to" values


diffs_

protected java.util.List<Difference> diffs_
The list of differences

Constructor Detail

Diff

public Diff(E[] aArray,
            E[] bArray,
            java.util.Comparator<E> comparator)
Constructs the Diff object by specifying two arrays and comparator.

Parameters:
aArray - the first input array for Diff
bArray - the second input array for Diff
comparator - the Diff comparator

Diff

public Diff(E[] aArray,
            E[] bArray)
Constructs the Diff object by specifying two arrays with the default comparison mechanism between the objects, such as equals and compareTo.

Parameters:
aArray - the first input array for Diff
bArray - the second input array for Diff

Diff

public Diff(java.util.List<E> aList,
            java.util.List<E> bList,
            java.util.Comparator<E> comparator)
Constructs the Diff object by specifying two lists and comparator.

Parameters:
aList - the first input list for Diff
bList - the second input list for Diff
comparator - the Diff comparator

Diff

public Diff(java.util.List<E> aList,
            java.util.List<E> bList)
Constructs the Diff object by specifying two lists with the default comparison mechanism between the objects, such as equals and compareTo.

Parameters:
aList - the first input list for Diff
bList - the second input list for Diff
Method Detail

GetDiff

public java.util.List<Difference> GetDiff()
Runs diff and get the results.

Returns:
a list of the result, Difference objects

VTT Java
2010 Version

Submit a bug or feature

Copyright © 2010 National Library of Medicine