Class IntDiffer

java.lang.Object
com.ibm.icu.dev.demo.translit.IntDiffer

public final class IntDiffer extends Object
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
    Modifier and Type
    Field
    Description
    private int[]
     
    private int
     
    private int
     
    private int[]
     
    private int
     
    private int
     
    private int
     
    private int
     
    private int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    IntDiffer(int stackSize, int matchCount)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    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
    Removes equal prefixes of both arrays.
    int
    getA(int offset)
     
    int
     
    int
    getB(int offset)
     
    int
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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.