Example usage for java.util Arrays copyOf

List of usage examples for java.util Arrays copyOf

Introduction

In this page you can find the example usage for java.util Arrays copyOf.

Prototype

public static boolean[] copyOf(boolean[] original, int newLength) 

Source Link

Document

Copies the specified array, truncating or padding with false (if necessary) so the copy has the specified length.

Usage

From source file:com.opengamma.analytics.math.surface.InterpolatedSurfaceAdditiveShiftFunction.java

/**
 * {@inheritDoc}//from w  w  w  . j av a  2  s .c  om
 */
@Override
public InterpolatedDoublesSurface evaluate(final InterpolatedDoublesSurface surface, final double shift,
        final String newName) {
    Validate.notNull(surface, "surface");
    final double[] xData = surface.getXDataAsPrimitive();
    final double[] yData = surface.getYDataAsPrimitive();
    final int n = xData.length;
    final double[] shiftedZ = Arrays.copyOf(surface.getZDataAsPrimitive(), n);
    for (int i = 0; i < n; i++) {
        shiftedZ[i] += shift;
    }
    return InterpolatedDoublesSurface.from(xData, yData, shiftedZ, surface.getInterpolator(), newName);
}

From source file:gaffer.function.ConsumerFunction.java

/**
 * @return Input record structure accepted by this <code>ConsumerFunction</code>.
 *//*w  w  w  . j  av a 2  s.c o  m*/
@JsonIgnore
public Class<?>[] getInputClasses() {
    if (null == inputs) {
        processInputAnnotation();
    }

    return Arrays.copyOf(inputs, inputs.length);
}

From source file:gaffer.function.simple.filter.MultiRegex.java

public void setPatterns(final Pattern[] patterns) {
    if (null != patterns) {
        this.patterns = Arrays.copyOf(patterns, patterns.length);
    } else {/* w w w  .j  ava2s.c  om*/
        this.patterns = new Pattern[0];
    }
}

From source file:com.opengamma.analytics.math.surface.InterpolatedSurfaceMultiplicativeShiftFunction.java

/**
 * {@inheritDoc}//from w ww  . ja va  2 s  . c  o m
 */
@Override
public InterpolatedDoublesSurface evaluate(final InterpolatedDoublesSurface surface, final double percentage,
        final String newName) {
    Validate.notNull(surface, "surface");
    final double[] xData = surface.getXDataAsPrimitive();
    final double[] yData = surface.getYDataAsPrimitive();
    final int n = xData.length;
    final double[] shiftedZ = Arrays.copyOf(surface.getZDataAsPrimitive(), n);
    for (int i = 0; i < n; i++) {
        shiftedZ[i] *= 1 + percentage;
    }
    return InterpolatedDoublesSurface.from(xData, yData, shiftedZ, surface.getInterpolator(), newName);
}

From source file:libepg.util.bytearray.ByteDataBlock.java

/**
 * ????????????/*  w w w.j ava 2s.co  m*/
 *
 * @return ??????????
 */
public synchronized final byte[] getData() {
    return Arrays.copyOf(this.data, this.data.length);
}

From source file:io.galeb.router.tests.hostselectors.AbstractHashHostSelectorTest.java

void doRandomTest(double errorPercentMax, double limitOfNotHitsPercent, int numPopulation) {
    final HttpServerExchange exchange = new HttpServerExchange(null);
    final Host[] newHosts = numPopulation < hosts.length ? Arrays.copyOf(hosts, numPopulation) : hosts;
    final Map<Integer, String> remains = IntStream.rangeClosed(0, newHosts.length - 1).boxed()
            .collect(Collectors.toMap(x -> x, x -> ""));

    for (int retry = 1; retry <= NUM_RETRIES; retry++) {
        final SummaryStatistics statisticsOfResults = new SummaryStatistics();

        final Map<Integer, Integer> mapOfResults = new HashMap<>();
        new Random().ints(numPopulation).map(Math::abs).forEach(x -> {
            changeExchange(exchange, x);
            int result = getResult(exchange, newHosts);
            Integer lastCount = mapOfResults.get(result);
            remains.remove(result);//  w  w  w . j  a v  a  2 s .  c o m
            mapOfResults.put(result, lastCount != null ? ++lastCount : 0);
        });
        mapOfResults.entrySet().stream().mapToDouble(Map.Entry::getValue)
                .forEach(statisticsOfResults::addValue);
        double errorPercent = (statisticsOfResults.getStandardDeviation() / numPopulation) * 100;
        assertThat(errorPercent, lessThan(errorPercentMax));
    }
    final List<Integer> listOfNotHit = remains.entrySet().stream().map(Map.Entry::getKey).collect(toList());
    assertThat(listOfNotHit.size(), lessThanOrEqualTo((int) (newHosts.length * (limitOfNotHitsPercent / 100))));
}

From source file:com.offbynull.voip.audio.gateways.io.internalmessages.InputPcmBlock.java

/**
 * Constructs an {@link InputPCMBlock} object.
 * @param data PCM data/*w w w. j  a  v a  2  s .c o m*/
 * @throws NullPointerException if any argument is {@code null}
 */
public InputPcmBlock(byte[] data) {
    Validate.notNull(data);
    this.data = Arrays.copyOf(data, data.length);
}

From source file:com.norconex.collector.core.crawler.event.CrawlerEventManager.java

public CrawlerEventManager(ICrawler crawler, ICrawlerEventListener[] listeners) {
    this.crawler = crawler;
    if (listeners != null) {
        this.listeners = Arrays.copyOf(listeners, listeners.length);
    } else {//from  www .j a v a2 s .c o  m
        this.listeners = new ICrawlerEventListener[] {};
    }
}

From source file:azkaban.flow.GroupedFlow.java

public GroupedFlow(Flow... flows) {
    this.flows = flows;
    this.sortedFlows = Arrays.copyOf(this.flows, this.flows.length);
    Arrays.sort(this.sortedFlows, new Comparator<Flow>() {
        @Override//from   w  ww .j  ava2 s .c om
        public int compare(Flow o1, Flow o2) {
            return o1.getName().compareTo(o2.getName());
        }
    });
}

From source file:com.offbynull.voip.audio.gateways.io.internalmessages.OutputPcmBlock.java

/**
 * Constructs an {@link OutputPCMBlock} object.
 * @param data PCM data//from  w ww  .j  a  v a 2 s .c o m
 * @throws NullPointerException if any argument is {@code null}
 */
public OutputPcmBlock(byte[] data) {
    Validate.notNull(data);
    this.data = Arrays.copyOf(data, data.length);
}