Class IntDiffer


  • public final class IntDiffer
    extends java.lang.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[] a  
      private int aCount  
      private int aTop  
      private int[] b  
      private int bCount  
      private int bTop  
      private int EQUALSIZE  
      private int maxSame  
      private int STACKSIZE  
    • Constructor Summary

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

      All Methods Instance Methods Concrete Methods 
      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 flush()
      Removes equal prefixes of both arrays.
      int getA​(int offset)  
      int getACount()  
      int getB​(int offset)  
      int getBCount()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • 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 Detail

      • 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 Detail

      • 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.