List of usage examples for java.util Arrays copyOfRange
public static boolean[] copyOfRange(boolean[] original, int from, int to)
From source file:io.cloudslang.lang.compiler.Extension.java
public static Extension[] getPropertiesFileExtensions() { return Arrays.copyOfRange(values(), 3, 4); }
From source file:name.abhijitsarkar.algorithms.core.Sorter.java
private static int[] recursiveMergeSort(int[] arr, int startIndex, int endIndex) { if (startIndex >= endIndex) { return Arrays.copyOfRange(arr, startIndex, endIndex + 1); }/*from w w w.ja va 2 s . c o m*/ final int middleIndex = (startIndex + endIndex) >> 1; int[] leftArr = recursiveMergeSort(arr, startIndex, middleIndex); int[] rightArr = recursiveMergeSort(arr, middleIndex + 1, endIndex); return merge(leftArr, rightArr); }
From source file:com.github.lxyscls.jvmjava.Cmd.java
static Cmd parseCmd(String[] args) throws ParseException { Cmd cmd = new Cmd(); Options options = new Options(); options.addOption("help", false, "print help message"); options.addOption("?", false, "print help message"); options.addOption("version", false, "print version and exit"); options.addOption("classpath", true, "classpath"); options.addOption("cp", true, "classpath"); options.addOption("Xjre", true, "path to jre"); CommandLineParser parser = new DefaultParser(); CommandLine cl = parser.parse(options, args); cmd.helpFlag = cl.hasOption("help") || cl.hasOption("?"); cmd.versionFlag = cl.hasOption("version"); if (cl.hasOption("classpath")) { cmd.cpOption = cl.getOptionValue("classpath"); } else if (cl.hasOption("cp")) { cmd.cpOption = cl.getOptionValue("cp"); }/*from w w w . j a va2 s .co m*/ if (cl.hasOption("Xjre")) { cmd.XjreOption = cl.getOptionValue("Xjre"); } String[] leftOverArgs = cl.getArgs(); if (leftOverArgs.length > 0) { cmd.runClass = leftOverArgs[0]; cmd.runClassArgs = Arrays.copyOfRange(leftOverArgs, 1, leftOverArgs.length); } return cmd; }
From source file:io.cloudslang.lang.compiler.Extension.java
public static String[] getYamlFileExtensionValues() { return Arrays.copyOfRange(extensionValues, 4, extensionValues.length); }
From source file:com.ning.arecibo.util.timeline.times.TimesAndSamplesCoder.java
public static byte[] getTimeBytes(final byte[] timesAndSamples) { final int timeByteCount = getSizeOfTimeBytes(timesAndSamples); return Arrays.copyOfRange(timesAndSamples, 4, 4 + timeByteCount); }
From source file:com.opengamma.analytics.math.statistics.descriptive.robust.InterquartileRangeCalculator.java
@Override public Double evaluate(final double[] x) { Validate.notNull(x, "x"); final int n = x.length; Validate.isTrue(n > 3, "Need at least four points to calculate IQR"); final double[] copy = Arrays.copyOf(x, n); Arrays.sort(copy);/*w w w . j av a2s.c o m*/ double[] lower, upper; if (n % 2 == 0) { lower = Arrays.copyOfRange(copy, 0, n / 2); upper = Arrays.copyOfRange(copy, n / 2, n); } else { lower = Arrays.copyOfRange(copy, 0, n / 2 + 1); upper = Arrays.copyOfRange(copy, n / 2, n); } return MEDIAN.evaluate(upper) - MEDIAN.evaluate(lower); }
From source file:ipLock.Signal.java
public static Signal valueOf(String data) { try {/* w w w . j a v a2s. c o m*/ String[] fields = StringUtils.split(data, ':'); Integer senderId = Integer.valueOf(fields[0]); SignalCode code = SignalCode.valueOf(fields[1]); String[] params = Arrays.copyOfRange(fields, 2, fields.length); return new Signal(senderId, code, params); } catch (RuntimeException e) { String msg = String.format("message '%s' can not be parsed into client signal", data); throw new IllegalArgumentException(msg, e); } }
From source file:Main.java
/**Split an array of any type at a position given by the second parameter. *<p>//from w w w . ja v a 2s .co m *If the third parameter is big enough to store the return, it will be stored there; otherwise a new array will be created. *@param array The array that will be splitted. *@param pos The position where the array will be splitted. *@param type The class of the copy to be returned. *@return An array of 2 arrays, where the first one has the element from 0 to pos and the second one has the elements from pos to array.length */ @SuppressWarnings("unchecked") public static <T> T[][] divideAt(T[] array, int pos, T[][] type) { Object[][] ret = { Arrays.copyOfRange(array, 0, pos), Arrays.copyOfRange(array, pos, array.length) }; return Arrays.asList(ret).toArray(type); }
From source file:com.ning.arecibo.util.timeline.times.TimesAndSamplesCoder.java
public static byte[] getSampleBytes(final byte[] timesAndSamples) { final int timeByteCount = getSizeOfTimeBytes(timesAndSamples); return Arrays.copyOfRange(timesAndSamples, 4 + timeByteCount, timesAndSamples.length); }
From source file:com.shuffle.p2p.Bytestring.java
private Bytestring cp9(int last, int next) { return new Bytestring(Arrays.copyOfRange(bytes, last, next)); }