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.interpolation.NaturalCubicSplineInterpolator1DNodeSensitivityCalculatorTest.java
private double getSensitivity(final Interpolator1DDataBundle model, final Interpolator1D interpolator, final double t, final int node) { final double[] x = model.getKeys(); final double[] y = model.getValues(); final int n = y.length; double[] yUp = new double[n]; double[] yDown = new double[n]; yUp = Arrays.copyOf(y, n); yDown = Arrays.copyOf(y, n);/*from ww w . ja v a 2s . c o m*/ yUp[node] += EPS; yDown[node] -= EPS; final Interpolator1DDataBundle modelUp = interpolator.getDataBundleFromSortedArrays(x, yUp); final Interpolator1DDataBundle modelDown = interpolator.getDataBundleFromSortedArrays(x, yDown); final double up = interpolator.interpolate(modelUp, t); final double down = interpolator.interpolate(modelDown, t); return (up - down) / 2.0 / EPS; }
From source file:it.unibo.alchemist.language.protelis.datatype.ArrayTupleImpl.java
@Override public Tuple append(final Object element) { final Object[] copy = Arrays.copyOf(a, a.length + 1); copy[a.length] = element;//from w w w . java 2s.c om return new ArrayTupleImpl(copy, false); }
From source file:com.navercorp.pinpoint.common.buffer.FixedBufferTest.java
@Test public void readPadBytes() { byte[] bytes = new byte[10]; random.nextBytes(bytes);//from ww w.ja v a 2 s.c om Buffer writeBuffer = new FixedBuffer(32); writeBuffer.putPadBytes(bytes, 20); writeBuffer.putInt(255); Buffer readBuffer = new FixedBuffer(writeBuffer.getBuffer()); byte[] readPadBytes = readBuffer.readPadBytes(20); Assert.assertArrayEquals(bytes, Arrays.copyOf(readPadBytes, 10)); int readInt = readBuffer.readInt(); Assert.assertEquals(255, readInt); }
From source file:hydrograph.engine.spark.datasource.delimited.HydrographDelimitedParser.java
public void reset(String delimiter, String quote, Type[] types, boolean strict, boolean safe, List<FastDateFormat> dateFormats, StructType schema) { if (delimiter == null || delimiter.isEmpty()) throw new IllegalArgumentException("delimiter may not be null or empty"); if (delimiter.equals(quote)) throw new IllegalArgumentException( "delimiter and quote character may not be the same value, got: '" + delimiter + "'"); this.delimiter = delimiter; this.strict = strict; this.safe = safe; this.schema = schema; this.dateFormats = dateFormats; if (quote != null && !quote.isEmpty()) // if empty, leave null this.quote = quote; if (types != null && types.length == 0) this.types = null; if (types != null) this.types = Arrays.copyOf(types, types.length); this.numValues = schema.length(); this.enforceStrict = this.strict; splitPattern = createSplitPatternFor(this.delimiter, this.quote); cleanPattern = createCleanPatternFor(this.quote); escapePattern = createEscapePatternFor(this.quote); }
From source file:com.cognifide.aet.worker.drivers.HttpRequestBuilderImpl.java
@Override public HttpRequestBuilderImpl setContent(byte[] content) { this.content = Arrays.copyOf(content, content.length); return this; }
From source file:co.runrightfast.vertx.orientdb.verticle.OrientDBVerticle.java
public OrientDBVerticle(final AppEventLogger appEventLogger, @NonNull final EmbeddedOrientDBServiceConfig config, final OrientDBRepositoryVerticleDeployment... orientDBRepositoryVerticleDeployments) { super(appEventLogger); config.validate();//w ww .j a va 2s . co m this.config = config; this.databaseClassesForHealthCheck = databaseClassesForHealthCheck(); if (ArrayUtils.isNotEmpty(orientDBRepositoryVerticleDeployments)) { this.orientDBRepositoryVerticleDeployments = Arrays.copyOf(orientDBRepositoryVerticleDeployments, orientDBRepositoryVerticleDeployments.length); } else { this.orientDBRepositoryVerticleDeployments = new OrientDBRepositoryVerticleDeployment[0]; } }
From source file:io.pivotal.spring.xd.jdbcgpfdist.support.ReadableTableFactoryBean.java
public void setForceQuote(String[] forceQuote) { this.forceQuote = Arrays.copyOf(forceQuote, forceQuote.length); }
From source file:com.microsoft.windowsazure.services.media.implementation.MediaRestProxy.java
@Override public MediaContract withFilter(ServiceFilter filter) { ServiceFilter[] filters = getFilters(); ServiceFilter[] newFilters = Arrays.copyOf(filters, filters.length + 1); newFilters[filters.length] = filter; return new MediaRestProxy(getChannel(), newFilters, clientConfigSettings); }
From source file:com.siphyc.utils.Utilities.java
public static byte[] getHalfOfByteArray(byte[] array) { return Arrays.copyOf(array, (array.length) / 2); }
From source file:com.apelon.akcds.loinc.CSVFileReader.java
@Override public String[] readLine() throws IOException { String[] temp = reader.readNext(); if (temp != null) { if (fieldCount_ == 0) { fieldCount_ = temp.length;//from w ww. j av a 2s . co m int i = 0; for (String s : temp) { fieldMapInverse_.put(i, s); fieldMap_.put(s, i++); } } else if (temp.length < fieldCount_) { temp = Arrays.copyOf(temp, fieldCount_); } else if (temp.length > fieldCount_) { throw new RuntimeException("Data error - to many fields found on line: " + Arrays.toString(temp)); } } return temp; }