Package com.ibm.icu.dev.demo.translit
Class IntDiffer
java.lang.Object
com.ibm.icu.dev.demo.translit.IntDiffer
VERY Basic Diff program. Compares two sequences of ints fed into it, and
lets you know where they are different.
This version compares ints while the CLDR class Differ compares Objects.
- Version:
- 1.0
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addA
(int aStr) void
addB
(int bStr) void
checkMatch
(boolean finalPass) Checks for initial & final match.private int
find
(int[] aArr, int aStart, int aEnd, int[] bArr, int bStart, int bEnd) Finds a segment of the first array in the second array.private void
flush()
Removes equal prefixes of both arrays.int
getA
(int offset) int
int
getB
(int offset) int
-
Field Details
-
STACKSIZE
private int STACKSIZE -
EQUALSIZE
private int EQUALSIZE -
a
private int[] a -
b
private int[] b -
aCount
private int aCount -
bCount
private int bCount -
maxSame
private int maxSame -
aTop
private int aTop -
bTop
private int bTop
-
-
Constructor Details
-
IntDiffer
public IntDiffer(int stackSize, int matchCount) - Parameters:
stackSize
- The size of the largest difference you expect.matchCount
- The number of items that have to be the same to count as a match
-
-
Method Details
-
addA
public void addA(int aStr) -
addB
public void addB(int bStr) -
getA
public int getA(int offset) -
getACount
public int getACount() -
getBCount
public int getBCount() -
getB
public int getB(int offset) -
checkMatch
public void checkMatch(boolean finalPass) Checks for initial & final match. To be called after addA() and addB(). Middle segments that are different are returned via get*Count() and get*().- Parameters:
finalPass
- true if no more input
-
find
private int find(int[] aArr, int aStart, int aEnd, int[] bArr, int bStart, int bEnd) Finds a segment of the first array in the second array.- Returns:
- -1 if not found, otherwise start position in bArr
-
flush
private void flush()Removes equal prefixes of both arrays.
-