int colsToRemove = region[1] - region[0] + 1;
hiddenColumns.remove(regionIndex);
numColumns -= colsToRemove;
-
- cursor.updateForDeletedRegion(hiddenColumns);
}
}
}
}
}
+ /**
+ * Answers true if obj is an instance of HiddenColumns, and holds the same
+ * array of start-end column ranges as this, else answers false
+ */
@Override
public boolean equals(Object obj)
{
{
LOCK.readLock().lock();
- int regionindex = cursor.findRegionForColumn(column, false)
- .getRegionIndex();
- if (regionindex > -1 && regionindex < hiddenColumns.size())
+ if (!hiddenColumns.isEmpty())
{
- int[] region = hiddenColumns.get(regionindex);
- // already know that column <= region[1] as cursor returns containing
- // region or region to right
- if (column >= region[0])
+ int regionindex = cursor.findRegionForColumn(column, false)
+ .getRegionIndex();
+ if (regionindex > -1 && regionindex < hiddenColumns.size())
{
- return false;
+ int[] region = hiddenColumns.get(regionindex);
+ // already know that column <= region[1] as cursor returns containing
+ // region or region to right
+ if (column >= region[0])
+ {
+ return false;
+ }
}
}
return true;
*/
public void hideColumns(BitSet inserts)
{
+ hideColumns(inserts, 0, inserts.length() - 1);
+ }
+
+ /**
+ * Hide columns corresponding to the marked bits, within the range
+ * [start,end]. Entries in tohide which are outside [start,end] are ignored.
+ *
+ * @param tohide
+ * columns mapped to bits starting from zero
+ * @param start
+ * start of range to hide columns within
+ * @param end
+ * end of range to hide columns within
+ */
+ private void hideColumns(BitSet tohide, int start, int end)
+ {
try
{
LOCK.writeLock().lock();
- for (int firstSet = inserts
- .nextSetBit(0), lastSet = 0; firstSet >= 0; firstSet = inserts
+ for (int firstSet = tohide
+ .nextSetBit(start), lastSet = start; firstSet >= start
+ && lastSet <= end; firstSet = tohide
.nextSetBit(lastSet))
{
- lastSet = inserts.nextClearBit(firstSet);
- hideColumns(firstSet, lastSet - 1);
+ lastSet = tohide.nextClearBit(firstSet);
+ if (lastSet <= end)
+ {
+ hideColumns(firstSet, lastSet - 1);
+ }
+ else if (firstSet <= end)
+ {
+ hideColumns(firstSet, end);
+ }
}
cursor = new HiddenColumnsCursor(hiddenColumns);
} finally
/**
* Hide columns corresponding to the marked bits, within the range
* [start,end]. Entries in tohide which are outside [start,end] are ignored.
+ * NB Existing entries in [start,end] are cleared.
*
* @param tohide
* columns mapped to bits starting from zero
* @param end
* end of range to hide columns within
*/
- public void hideColumns(BitSet tohide, int start, int end)
+ public void clearAndHideColumns(BitSet tohide, int start, int end)
{
clearHiddenColumnsInRange(start, end);
-
- // make sure only bits between start and end are set
- if (!tohide.isEmpty())
- {
- tohide.clear(0, start);
- tohide.clear(Math.min(end + 1, tohide.length() + 1),
- tohide.length() + 1);
- }
-
- hideColumns(tohide);
+ hideColumns(tohide, start, end);
}
/**
try
{
LOCK.readLock().lock();
- return new HiddenColsIterator(hiddenColumns);
+ return new RangeIterator(hiddenColumns);
} finally
{
LOCK.readLock().unlock();
try
{
LOCK.readLock().lock();
- return new HiddenColsIterator(start, end, hiddenColumns);
+ return new RangeIterator(start, end, hiddenColumns);
} finally
{
LOCK.readLock().unlock();
* @param end
* position to end at (inclusive, visible column position)
*/
- public Iterator<Integer> getBoundedStartIterator(int start, int end)
+ public Iterator<Integer> getStartRegionIterator(int start, int end)
{
try
{
HiddenCursorPosition pos = cursor
.findRegionForColumn(absoluteStart - 1, false);
- return new BoundedStartRegionIterator(pos, start, end,
+ return new StartRegionIterator(pos, start, end,
hiddenColumns);
} finally
{
try
{
LOCK.readLock().lock();
- return new VisibleColsIterator(start, end, hiddenColumns);
+ return new RangeElementsIterator(
+ new VisibleContigsIterator(start, end + 1, hiddenColumns));
} finally
{
LOCK.readLock().unlock();