X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Futil%2FMappingUtils.java;h=fe95f4b3f367727bc7031cf3c864554e3074f80c;hb=304e64fb34b32659be1bbfd39fb4e15b2f79586e;hp=cd8821def75f988e10ea52a41f6bba3c575a29b7;hpb=cfb79b69d9fa44595560659bd95d1d1cd27677ad;p=jalview.git diff --git a/src/jalview/util/MappingUtils.java b/src/jalview/util/MappingUtils.java index cd8821d..fe95f4b 100644 --- a/src/jalview/util/MappingUtils.java +++ b/src/jalview/util/MappingUtils.java @@ -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 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; + } }