Example usage for java.util Arrays parallelSort

List of usage examples for java.util Arrays parallelSort

Introduction

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

Prototype

@SuppressWarnings("unchecked")
public static <T extends Comparable<? super T>> void parallelSort(T[] a) 

Source Link

Document

Sorts the specified array of objects into ascending order, according to the Comparable natural ordering of its elements.

Usage

From source file:Main.java

public static void main(String[] args) throws FileNotFoundException {
    List<Integer> arraySource = new ArrayList<>();
    for (int i = 0; i < 99999; i++) {
        arraySource.add(i);/*from   w  w w . j a  v  a  2  s. c o m*/
    }

    Integer[] myArray = new Integer[999];
    myArray = arraySource.toArray(myArray);
    long startTime = System.currentTimeMillis();
    Arrays.sort(myArray);
    long endTime = System.currentTimeMillis();
    System.out.println("Time take in serial: " + (endTime - startTime) / 1000.0);

    Integer[] myArray2 = new Integer[999];
    myArray2 = arraySource.toArray(myArray);
    startTime = System.currentTimeMillis();
    Arrays.parallelSort(myArray2);
    endTime = System.currentTimeMillis();
    System.out.println("Time take in parallel: " + (endTime - startTime) / 1000.0);

}

From source file:jsat.distributions.empirical.MyKernelDensityEstimator.java

private void setUpX(Vec S) {
    Xmean = S.mean();//w  w  w . j  a  v  a  2  s .  c  o  m
    Xvar = S.variance();
    Xskew = S.skewness();
    X = S.arrayCopy();
    Arrays.parallelSort(X);
    sumOFWeights = X.length;
    weights = new double[0];
}

From source file:ijfx.ui.plugin.panel.OverlayPanel.java

protected XYChart.Series<Double, Double> getOverlayHistogram(Overlay overlay) {

    Timer timer = timerService.getTimer(this.getClass());
    timer.start();//from  w ww . j  av  a 2 s .  c  o  m
    Double[] valueList = statsService.getValueList(currentDisplay(), overlay);
    timer.elapsed("Getting the stats");
    SummaryStatistics sumup = new SummaryStatistics();
    for (Double v : valueList) {
        sumup.addValue(v);
    }
    timer.elapsed("Building the sumup");

    double min = sumup.getMin();
    double max = sumup.getMax();
    double range = max - min;
    int bins = 100;//new Double(max - min).intValue();

    EmpiricalDistribution distribution = new EmpiricalDistribution(bins);

    double[] values = ArrayUtils.toPrimitive(valueList);
    Arrays.parallelSort(values);
    distribution.load(values);

    timer.elapsed("Sort and distrubution repartition up");

    XYChart.Series<Double, Double> serie = new XYChart.Series<>();
    ArrayList<Data<Double, Double>> data = new ArrayList<>(bins);
    double k = min;
    for (SummaryStatistics st : distribution.getBinStats()) {
        data.add(new Data<Double, Double>(k, new Double(st.getN())));
        k += range / bins;
    }

    serie.getData().clear();
    serie.getData().addAll(data);
    timer.elapsed("Creating charts");
    return serie;
}

From source file:ijfx.ui.plugin.overlay.OverlayPanel.java

protected XYChart.Series<Double, Double> getOverlayHistogram(Overlay overlay) {

    Timer timer = timerService.getTimer(this.getClass());
    timer.start();//  www  .jav  a  2  s  .  com
    Double[] valueList = statsService.getValueListFromImageDisplay(currentDisplay(), overlay);
    timer.elapsed("Getting the stats");
    SummaryStatistics sumup = new SummaryStatistics();
    for (Double v : valueList) {
        sumup.addValue(v);
    }
    timer.elapsed("Building the sumup");

    double min = sumup.getMin();
    double max = sumup.getMax();
    double range = max - min;
    int bins = 100;//new Double(max - min).intValue();

    EmpiricalDistribution distribution = new EmpiricalDistribution(bins);

    double[] values = ArrayUtils.toPrimitive(valueList);
    Arrays.parallelSort(values);
    distribution.load(values);

    timer.elapsed("Sort and distrubution repartition up");

    XYChart.Series<Double, Double> serie = new XYChart.Series<>();
    ArrayList<Data<Double, Double>> data = new ArrayList<>(bins);
    double k = min;
    for (SummaryStatistics st : distribution.getBinStats()) {
        data.add(new Data<Double, Double>(k, new Double(st.getN())));
        k += range / bins;
    }

    serie.getData().clear();
    serie.getData().addAll(data);
    timer.elapsed("Creating charts");
    return serie;
}

From source file:nl.umcg.westrah.binarymetaanalyzer.BinaryMetaAnalysis.java

private void addEQTL(QTL q) {

    double pval = q.getPvalue();

    //      // sort every 1E7 results
    //      if (locationToStoreResult > 1E7 && locationToStoreResult % 1E7 == 0) {
    ////         System.out.println("Sorting intermediate output.");
    //         Arrays.parallelSort(finalEQTLs, 0, locationToStoreResult);
    ////         System.out.println("Done sorting...");
    //      }/*from   w  ww.  j ava  2 s .  co m*/

    if (bufferHasOverFlown) {
        if (pval <= maxSavedPvalue) {

            sorted = false;

            finalEQTLs[locationToStoreResult] = q;
            locationToStoreResult++;

            if (locationToStoreResult == finalEQTLs.length) { // note that finalEQTLs has size: QTL[settings.getFinalEQTLBufferMaxLength()+tmpbuffersize]

                Arrays.parallelSort(finalEQTLs);
                sorted = true;
                locationToStoreResult = settings.getFinalEQTLBufferMaxLength();
                maxSavedPvalue = finalEQTLs[(settings.getFinalEQTLBufferMaxLength() - 1)].getPvalue();
            }
        }

    } else {
        if (pval > maxSavedPvalue) {
            maxSavedPvalue = pval;
        }

        finalEQTLs[locationToStoreResult] = q;
        locationToStoreResult++;

        if (locationToStoreResult == settings.getFinalEQTLBufferMaxLength()) {
            bufferHasOverFlown = true;
        }
    }
}