|
VTT Java 2010 Version |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgov.nih.nlm.nls.vtt.Lib.Diff<E>
public class Diff<E>
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:
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 |
---|
protected java.util.List<E> aList_
protected java.util.List<E> bList_
protected java.util.List<Difference> diffs_
Constructor Detail |
---|
public Diff(E[] aArray, E[] bArray, java.util.Comparator<E> comparator)
aArray
- the first input array for DiffbArray
- the second input array for Diffcomparator
- the Diff comparatorpublic Diff(E[] aArray, E[] bArray)
equals
and
compareTo
.
aArray
- the first input array for DiffbArray
- the second input array for Diffpublic Diff(java.util.List<E> aList, java.util.List<E> bList, java.util.Comparator<E> comparator)
aList
- the first input list for DiffbList
- the second input list for Diffcomparator
- the Diff comparatorpublic Diff(java.util.List<E> aList, java.util.List<E> bList)
equals
and
compareTo
.
aList
- the first input list for DiffbList
- the second input list for DiffMethod Detail |
---|
public java.util.List<Difference> GetDiff()
|
VTT Java 2010 Version |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |