JAL-2759 Changes to StartRegionIterator after review
[jalview.git] / src / jalview / datamodel / StartRegionIterator.java
@@ -8,7 +8,7 @@ import java.util.List;
  * An iterator which iterates over visible start positions of hidden column
  * regions in a range.
  */
-public class BoundedStartRegionIterator implements Iterator<Integer>
+public class StartRegionIterator implements Iterator<Integer>
 {
   // start position to iterate from
   private int start;
@@ -33,43 +33,10 @@ public class BoundedStartRegionIterator implements Iterator<Integer>
    *          whether to make a local copy of hiddenColumns for iteration (set
    *          to true if calling from outwith the HiddenColumns class)
    */
-  BoundedStartRegionIterator(int lowerBound, int upperBound,
+  StartRegionIterator(int lowerBound, int upperBound,
           List<int[]> hiddenColumns)
   {
-    start = lowerBound;
-    end = upperBound;
-
-    if (hiddenColumns != null)
-    {
-      positions = new ArrayList<>(hiddenColumns.size());
-
-      // navigate to start, keeping count of hidden columns
-      int i = 0;
-      int hiddenSoFar = 0;
-      while ((i < hiddenColumns.size())
-              && (hiddenColumns.get(i)[0] < start + hiddenSoFar))
-      {
-        int[] region = hiddenColumns.get(i);
-        hiddenSoFar += region[1] - region[0] + 1;
-        i++;
-      }
-
-      // iterate from start to end, adding start positions of each
-      // hidden region. Positions are visible columns count, not absolute
-      while (i < hiddenColumns.size()
-              && (hiddenColumns.get(i)[0] <= end + hiddenSoFar))
-      {
-        int[] region = hiddenColumns.get(i);
-        positions.add(region[0] - hiddenSoFar);
-        hiddenSoFar += region[1] - region[0] + 1;
-        i++;
-      }
-    }
-    else
-    {
-      positions = new ArrayList<>();
-    }
-
+    this(null, lowerBound, upperBound, hiddenColumns);
   }
 
   /**
@@ -84,7 +51,7 @@ public class BoundedStartRegionIterator implements Iterator<Integer>
    * @param hiddenColumns
    *          the hidden columns collection to use
    */
-  BoundedStartRegionIterator(HiddenCursorPosition pos, int lowerBound,
+  StartRegionIterator(HiddenCursorPosition pos, int lowerBound,
           int upperBound, List<int[]> hiddenColumns)
   {
     start = lowerBound;