mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-02-23 13:09:00 +00:00
(coded-sequence) Correct behavior of findIntersections
This commit is contained in:
parent
fdf05cedae
commit
805cb5ad58
@ -87,6 +87,9 @@ public class SequenceOperations {
|
||||
|
||||
if (indexes[i] < positions[i].size()) {
|
||||
values[i] = positions[i].getInt(indexes[i]++) + offsets[i];
|
||||
|
||||
// Update the maximum value, if necessary
|
||||
max = Math.max(max, values[i]);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
@ -177,18 +180,22 @@ public class SequenceOperations {
|
||||
|
||||
minDist = Math.min(minDist, maxVal - minVal);
|
||||
|
||||
for (int i = 0;; i = (i + 1) % positions.length)
|
||||
{
|
||||
if (values[i] == minVal) {
|
||||
for (;;) {
|
||||
for (int i = 0; i < positions.length; i++) {
|
||||
if (values[i] > minVal) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (indexes[i] < positions[i].size()) {
|
||||
values[i] = positions[i].getInt(indexes[i]++) + offsets[i];
|
||||
} else {
|
||||
break;
|
||||
return minDist;
|
||||
}
|
||||
|
||||
if (values[i] > maxVal) {
|
||||
maxVal = values[i];
|
||||
}
|
||||
|
||||
if (values[i] > minVal) {
|
||||
minVal = Integer.MAX_VALUE;
|
||||
for (int val : values) {
|
||||
@ -199,7 +206,5 @@ public class SequenceOperations {
|
||||
minDist = Math.min(minDist, maxVal - minVal);
|
||||
}
|
||||
}
|
||||
|
||||
return minDist;
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ class SequenceOperationsTest {
|
||||
GammaCodedSequence seq2 = GammaCodedSequence.generate(wa, 2, 5, 8, 10, 14);
|
||||
GammaCodedSequence seq3 = GammaCodedSequence.generate(wa, 1, 5, 8, 9, 10);
|
||||
|
||||
assertEquals(IntList.of(8, 10), SequenceOperations.findIntersections(seq1.iterator(), seq2.iterator(), seq3.iterator()));
|
||||
assertEquals(IntList.of(8, 10), SequenceOperations.findIntersections(seq1.values(), seq2.values(), seq3.values()));
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user