Skip to content

Commit d506d62

Browse files
committed
added a default method for computeDiff from arrays
1 parent 33f2d74 commit d506d62

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/main/java/com/github/difflib/algorithm/DiffAlgorithmI.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@
1515
*/
1616
package com.github.difflib.algorithm;
1717

18+
import java.util.Arrays;
1819
import java.util.List;
1920

2021
/**
2122
* Interface of a diff algorithm.
22-
*
23+
*
2324
* @author Tobias Warneke (t.warneke@gmx.net)
2425
*/
2526
public interface DiffAlgorithmI<T> {
26-
27+
2728
/**
2829
* Computes the changeset to patch the source list to the target list.
2930
*
@@ -34,4 +35,17 @@ public interface DiffAlgorithmI<T> {
3435
* @throws DiffException
3536
*/
3637
List<Change> computeDiff(List<T> source, List<T> target, DiffAlgorithmListener progress) throws DiffException;
38+
39+
/**
40+
* Simple extension to compute a changeset using arrays.
41+
*
42+
* @param source
43+
* @param target
44+
* @param progress
45+
* @return
46+
* @throws com.github.difflib.algorithm.DiffException
47+
*/
48+
default List<Change> computeDiff(T[] source, T[] target, DiffAlgorithmListener progress) throws DiffException {
49+
return computeDiff(Arrays.asList(source), Arrays.asList(target), progress);
50+
}
3751
}

0 commit comments

Comments
 (0)