+ }
+ }
+
+ @Override
+ public boolean hasNext()
+ {
+ return (hiddenColumns != null) && (nextRegion != null)
+ && (nextRegion[0] <= end);
+ }
+
+ @Override
+ public int[] next()
+ {
+ int[] region = nextRegion;
+ currentPosition++;
+ if (currentPosition < hiddenColumns.size())
+ {
+ nextRegion = hiddenColumns.get(currentPosition);
+ }
+ else
+ {
+ nextRegion = null;
+ }
+ return region;
+ }
+
+ }
+
+ /**
+ * An iterator which iterates over hidden column regions in a range. Works
+ * with a copy of the hidden columns collection.
+ */
+ private class BoundedHiddenColsIterator implements Iterator<int[]>
+ {
+ private int start; // start position to iterate from
+
+ private int end; // end position to iterate to
+
+ // current index in hiddenColumns
+ private int currentPosition = 0;
+
+ // current column in hiddenColumns
+ private int[] currentRegion;
+
+ // local copy or reference to hiddenColumns
+ private List<int[]> localHidden;
+
+ BoundedHiddenColsIterator()
+ {
+ if (hiddenColumns != null)
+ {
+ int last = hiddenColumns.get(hiddenColumns.size() - 1)[1];
+ init(0, last);
+ }
+ else
+ {
+ init(0, 0);
+ }
+ }
+
+ /**
+ * Construct an iterator over hiddenColums bounded at
+ * [lowerBound,upperBound]
+ *
+ * @param lowerBound
+ * lower bound to iterate from
+ * @param upperBound
+ * upper bound to iterate to
+ */
+ BoundedHiddenColsIterator(int lowerBound, int upperBound)
+ {
+ init(lowerBound, upperBound);
+ }
+
+ /**
+ * Construct an iterator over hiddenColums bounded at
+ * [lowerBound,upperBound]
+ *
+ * @param lowerBound
+ * lower bound to iterate from
+ * @param upperBound
+ * upper bound to iterate to
+ */
+ private void init(int lowerBound, int upperBound)
+ {
+ start = lowerBound;
+ end = upperBound;
+
+ try
+ {
+ LOCK.readLock().lock();