Merge commit 'alpha/update_2_12_for_2_11_2_series_merge^2' into HEAD
[jalview.git] / src / jalview / util / MappingUtils.java
index cd8821d..fe95f4b 100644 (file)
@@ -1020,7 +1020,6 @@ public final class MappingUtils
       }
     }
   }
-
   /**
    * Adds the given range to a list of ranges. If the new range just extends
    * existing ranges, the current endpoint is updated instead.
@@ -1075,4 +1074,25 @@ public final class MappingUtils
      */
     addTo.add(range);
   }
+
+  /**
+   * Converts a list of {@code start-end} ranges to a single array of
+   * {@code start1, end1, start2, ... } ranges
+   * 
+   * @param ranges
+   * @return
+   */
+  public static int[] rangeListToArray(List<int[]> ranges)
+  {
+    int rangeCount = ranges.size();
+    int[] result = new int[rangeCount * 2];
+    int j = 0;
+    for (int i = 0; i < rangeCount; i++)
+    {
+      int[] range = ranges.get(i);
+      result[j++] = range[0];
+      result[j++] = range[1];
+    }
+    return result;
+  }
 }