mirror of
https://github.com/java-diff-utils/java-diff-utils.git
synced 2026-03-13 10:11:17 +08:00
removed bootstrap test to allow reversed search
This commit is contained in:
@@ -111,7 +111,7 @@ public final class MyersDiff<T> implements DiffAlgorithm<T> {
|
||||
final int middle = size / 2;
|
||||
final PathNode diagonal[] = new PathNode[size];
|
||||
|
||||
diagonal[middle + 1] = new PathNode(0, -1, true, null);
|
||||
diagonal[middle + 1] = new PathNode(0, -1, true, true, null);
|
||||
for (int d = 0; d < MAX; d++) {
|
||||
for (int k = -d; k <= d; k += 2) {
|
||||
final int kmiddle = middle + k;
|
||||
@@ -132,7 +132,7 @@ public final class MyersDiff<T> implements DiffAlgorithm<T> {
|
||||
|
||||
int j = i - k;
|
||||
|
||||
PathNode node = new PathNode(i, j, false, prev);
|
||||
PathNode node = new PathNode(i, j, false, false, prev);
|
||||
|
||||
while (i < N && j < M && equalizer.equals(orig.get(i), rev.get(j))) {
|
||||
i++;
|
||||
@@ -140,7 +140,7 @@ public final class MyersDiff<T> implements DiffAlgorithm<T> {
|
||||
}
|
||||
|
||||
if (i != node.i) {
|
||||
node = new PathNode(i, j, true, node);
|
||||
node = new PathNode(i, j, true, false, node);
|
||||
}
|
||||
|
||||
diagonal[kmiddle] = node;
|
||||
|
||||
@@ -44,6 +44,8 @@ public final class PathNode {
|
||||
public final PathNode prev;
|
||||
|
||||
public final boolean snake;
|
||||
|
||||
public final boolean bootstrap;
|
||||
|
||||
/**
|
||||
* Concatenates a new path node with an existing diffpath.
|
||||
@@ -52,9 +54,10 @@ public final class PathNode {
|
||||
* @param j The position in the revised sequence for the new node.
|
||||
* @param prev The previous node in the path.
|
||||
*/
|
||||
public PathNode(int i, int j, boolean snake, PathNode prev) {
|
||||
public PathNode(int i, int j, boolean snake, boolean bootstrap, PathNode prev) {
|
||||
this.i = i;
|
||||
this.j = j;
|
||||
this.bootstrap = bootstrap;
|
||||
if (snake) {
|
||||
this.prev = prev;
|
||||
} else {
|
||||
@@ -75,7 +78,7 @@ public final class PathNode {
|
||||
* @return tru if this is a bootstrap node.
|
||||
*/
|
||||
public boolean isBootstrap() {
|
||||
return i < 0 || j < 0;
|
||||
return bootstrap;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user