List of usage examples for java.util Arrays copyOf
public static boolean[] copyOf(boolean[] original, int newLength)
From source file:com.opengamma.strata.math.impl.statistics.descriptive.PercentileCalculatorTest.java
private void assertResult(final double[] x, final int percentile) { final double[] copy = Arrays.copyOf(x, N); Arrays.sort(copy);/* w w w . j a v a2 s . c o m*/ int count = 0; CALCULATOR.setPercentile(((double) percentile) / N); final double value = CALCULATOR.apply(x); while (copy[count++] < value) { //intended } assertEquals(count - 1, percentile); }
From source file:io.codis.nedis.util.NedisUtils.java
public static byte[][] toParams(byte[][] headParams, byte[]... tailParams) { byte[][] params = Arrays.copyOf(headParams, headParams.length + tailParams.length); System.arraycopy(tailParams, 0, params, headParams.length, tailParams.length); return params; }
From source file:jease.cms.web.content.ContentTableModel.java
/** * Which column names should be displayed as headers? *//*w ww . j a va 2s.co m*/ public String[] getColumns() { String[] columns = new String[] { I18N.get("Type"), I18N.get("Id"), I18N.get("Name"), I18N.get("Last_modified"), I18N.get("Editor"), I18N.get("Size"), I18N.get("Visible") }; if (registry.getParameter(Names.JEASE_SITE_DESIGN) != null) { return columns; } else { return Arrays.copyOf(columns, columns.length - 1); } }
From source file:net.nicholaswilliams.java.licensing.licensor.interfaces.cli.TestPeriods.java
@Test public void testRun02() throws InterruptedException { Thread thread = new Thread(this.periods); thread.start();/*from www .j av a 2s .co m*/ Thread.sleep(200); thread.interrupt(); byte[] bytes = this.outputStream.toByteArray(); assertTrue("The length is not correct.", bytes.length >= 6); assertArrayEquals("The arrays are not correct.", Arrays.copyOf(bytes, 6), new byte[] { '.', '.', '.', '.', '.', '.' }); }
From source file:com.palantir.atlasdb.cli.runner.AbstractTestRunner.java
@Override public void parse(String... args) { this.args = Arrays.copyOf(args, args.length); }
From source file:com.ktds.ldap.populator.AttributeCheckAttributesMapper.java
public void setExpectedAttributes(String[] expectedAttributes) { this.expectedAttributes = Arrays.copyOf(expectedAttributes, expectedAttributes.length); }
From source file:com.opengamma.financial.analytics.LabelledMatrix2D.java
public LabelledMatrix2D(final S[] xKeys, final Object[] xLabels, final String xTitle, final T[] yKeys, final Object[] yLabels, final String yTitle, final double[][] values, final String valuesTitle) { Validate.notNull(xKeys, "x keys"); final int m = xKeys.length; Validate.notNull(xLabels, "x labels"); Validate.isTrue(xLabels.length == m); Validate.notNull(yKeys, "y keys"); final int n = yKeys.length; Validate.notNull(yLabels, "y labels"); Validate.notNull(yLabels.length == n); Validate.notNull(values, "values"); Validate.isTrue(values.length == n, "number of rows of data and y keys must be the same length"); _xKeys = Arrays.copyOf(xKeys, m); _yKeys = Arrays.copyOf(yKeys, n); _xLabels = new Object[m]; _yLabels = new Object[n]; _xTitle = xTitle;/*from w ww . j av a 2s . c o m*/ _yTitle = yTitle; _values = new double[n][m]; for (int i = 0; i < n; i++) { Validate.isTrue(values[i].length == m, "number of columns of data and x keys must be the same length"); _yLabels[i] = yLabels[i]; for (int j = 0; j < m; j++) { if (i == 0) { _xLabels[j] = xLabels[j]; } _values[i][j] = values[i][j]; } } _valuesTitle = valuesTitle; quickSortX(); quickSortY(); }
From source file:edu.emory.mathcs.nlp.learn.weight.MultinomialWeightVector.java
@Override public boolean expand(int labelSize, int featureSize) { if (labelSize < label_size || featureSize < feature_size || (labelSize == label_size && featureSize == feature_size)) return false; int i, j, diff = labelSize - label_size; float[] vector; if (diff > 0) { vector = new float[labelSize * featureSize]; int size = label_size * feature_size; for (i = 0, j = 0; i < size; i++, j++) { if (i > 0 && i % label_size == 0) j += diff;//from ww w . j ava 2 s . c o m vector[j] = weight_vector[i]; } } else vector = Arrays.copyOf(weight_vector, labelSize * featureSize); weight_vector = vector; label_size = labelSize; feature_size = featureSize; return true; }
From source file:com.simiacryptus.util.io.IOUtil.java
/** * Write kryo.//from w w w . j a va 2 s.c o m * * @param <T> the type parameter * @param obj the obj * @param file the file */ public static <T> void writeKryo(T obj, OutputStream file) { try { Output output = new Output(buffer.get()); new KryoReflectionFactorySupport().writeClassAndObject(output, obj); output.close(); IOUtils.write(CompressionUtil.encodeBZ(Arrays.copyOf(output.getBuffer(), output.position())), file); file.close(); } catch (IOException e) { throw new RuntimeException(e); } }
From source file:com.adobe.acs.commons.notifications.impl.InboxNotificationImpl.java
public void setNotificationActions(String... notificationActions) { if (notificationActions == null) { this.notificationActions = ArrayUtils.EMPTY_STRING_ARRAY; } else {//from ww w . ja v a 2 s . co m this.notificationActions = Arrays.copyOf(notificationActions, notificationActions.length); } }