Created
April 4, 2018 14:21
-
-
Save tindzk/527a73a6b280ac30daf5ba1bd182bd07 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.collection.mutable | |
import scala.collection.JavaConverters._ | |
import org.eclipse.jgit.diff.{HistogramDiff, Sequence, SequenceComparator} | |
val histogramDiff = new HistogramDiff() | |
histogramDiff.setFallbackAlgorithm(null) | |
val deltas = histogramDiff.diff( | |
new DataListComparator[Char], | |
new DataList(input.toBuffer), | |
new DataList(output.toBuffer) | |
).asScala | |
// ... | |
class DataListComparator[T] extends SequenceComparator[DataList[T]] { | |
override def equals(original: DataList[T], | |
orgIdx: Int, | |
revised: DataList[T], | |
revIdx: Int): Boolean = | |
original.data(orgIdx).equals(revised.data(revIdx)) | |
override def hash(s: DataList[T], i: Int): Int = s.data(i).hashCode() | |
} | |
class DataList[T](val data: mutable.Buffer[T]) extends Sequence { | |
def size(): Int = data.length | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment