Skip to content

Commit 9e99706

Browse files
committed
More work on integrating gaf.
1 parent 3c2fb51 commit 9e99706

File tree

5 files changed

+309
-179
lines changed

5 files changed

+309
-179
lines changed

include/superintervals.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ class SuperIntervals {
174174
size_t i = idx;
175175
while (i > 0) {
176176
if (start <= ends[i]) {
177+
std::cout << " si " << start << " <= " << starts[i] << "-" << ends[i] << " " << i << std::endl;
177178
found.push_back(data[i]);
178179
--i;
179180
} else {
@@ -241,15 +242,20 @@ class SuperIntervals {
241242
size_t it_start = 0;
242243
while (it_start < starts.size()) {
243244
size_t block_end = it_start + 1;
244-
bool needs_sort = false;
245+
// Find the end of this block (all with same start value)
245246
while (block_end < starts.size() && starts[block_end] == starts[it_start]) {
246-
if (block_end > it_start && ends[block_end] > ends[block_end - 1]) {
247+
++block_end;
248+
}
249+
// Check if this block needs sorting, scan entire block to ensure descending order of ends
250+
bool needs_sort = false;
251+
for (size_t i = it_start + 1; i < block_end && !needs_sort; ++i) {
252+
if (ends[i] > ends[i - 1]) {
247253
needs_sort = true;
248254
}
249-
++block_end;
250255
}
251256
if (needs_sort) {
252-
sortBlock(it_start, block_end, [](const Interval& a, const Interval& b) { return a.end > b.end; });
257+
sortBlock(it_start, block_end,
258+
[](const Interval& a, const Interval& b) { return a.end > b.end; });
253259
}
254260
it_start = block_end;
255261
}

0 commit comments

Comments
 (0)