hiddenCount -= region[1] - region[0] + 1;
}
- if ((hiddenColumns.get(index)[0] <= column)
- && hiddenColumns.get(index)[1] >= column)
- {
- // column is in the current region
- // we hit the jackpot
- // don't need to move index
- }
- else if (column < firstColumn)
+ // this if statement excludes case where column is in current region
+ // - no changes needed
+ if (column < firstColumn)
{
index = 0;
hiddenCount = 0;
}
// column is after current region
- else if (column > hiddenColumns.get(index)[1]) // includes if column >
- // lastColumn
+ else if (column > hiddenColumns.get(index)[1])
{
// iterate from where we are now, if we're lucky we'll be close by
// (but still better than iterating from 0)
index++;
}
}
-
// column is before current region
else if (column < hiddenColumns.get(index)[0])
{
// column is before or in the previous region
- if ((index > 0) && (hiddenColumns.get(index - 1)[1] >= column))
+ while ((index > 0) && (hiddenColumns.get(index - 1)[1] >= column))
{
- while ((index > 0) && (hiddenColumns.get(index - 1)[1] >= column))
- {
- index--;
- int[] region = hiddenColumns.get(index);
- hiddenCount -= region[1] - region[0] + 1;
- }
+ index--;
+ int[] region = hiddenColumns.get(index);
+ hiddenCount -= region[1] - region[0] + 1;
}
}