Example usage for java.util Collections min

List of usage examples for java.util Collections min

Introduction

In this page you can find the example usage for java.util Collections min.

Prototype

public static <T extends Object & Comparable<? super T>> T min(Collection<? extends T> coll) 

Source Link

Document

Returns the minimum element of the given collection, according to the natural ordering of its elements.

Usage

From source file:be.ugent.maf.cellmissy.gui.controller.analysis.doseresponse.generic.GenericDRNormalizedController.java

@Override
public void initDRNormalizedData() {
    //set constrain combo boxes to standard setting: means
    dRNormalizedPlotPanel.getBottomComboBox().setSelectedIndex(0);
    dRNormalizedPlotPanel.getTopComboBox().setSelectedIndex(0);
    //set initial parameters
    dRNormalizedPlotPanel.getBottomTextField().setText(AnalysisUtils
            .roundTwoDecimals(Collections.min(computeMeans(
                    getAllResponses(doseResponseController.getdRAnalysisGroup().getDoseResponseData()))))
            .toString());// ww  w.ja va2 s  .  co m
    dRNormalizedPlotPanel.getTopTextField().setText(AnalysisUtils
            .roundTwoDecimals(Collections.max(computeMeans(
                    getAllResponses(doseResponseController.getdRAnalysisGroup().getDoseResponseData()))))
            .toString());
    //LogTransform concentrations and perform initial normalization (mean values)
    dataToFit = prepareFittingData(doseResponseController.getdRAnalysisGroup().getDoseResponseData(),
            doseResponseController.getLogTransform());
    //create and set the table model for the top panel table (dependent on normalization)
    setTableModel(doseResponseController.updateTableModel(createTableModel(dataToFit)));
    //Perform initial curve fitting (standard hillslope, no constraints)
    doseResponseController.performFitting(dataToFit, doseResponseController.getdRAnalysisGroup()
            .getDoseResponseAnalysisResults().getFittingResults(true), null, null);
}

From source file:com.sloshydog.timely.EventRecorder.java

public List<TimedEvent> getTimedEvents() {
    long buildStartTime = Collections.min(startTimes.values());

    List<TimedEvent> timedEvents = new ArrayList<TimedEvent>();
    for (ExecutionEventKey key : startTimes.keySet()) {
        if (!endTimes.containsKey(key)) {
            throw new IllegalStateException(format("No end time recorded for event '%s'", key.toString()));
        }//from   www  .  j a  v a 2  s. c  o m
        timedEvents.add(
                new TimedEvent(key, startTimes.get(key) - buildStartTime, endTimes.get(key) - buildStartTime));
    }

    Collections.sort(timedEvents);

    return timedEvents;
}

From source file:org.cbioportal.genome_nexus.annotation.util.Numerical.java

/**
  * Checks if the given input value overlaps the start and end values.
  * Input value can be a range value too.
  */*from www  .j av  a2s. com*/
  * This function assumes that start value is smaller than the end value.
  *
  * @param input input string (a single value or a range value)
  * @param start start value
  * @param end   end value
  * @return      true if there is an overlap between values
  */
public static boolean overlaps(String input, String start, String end) {
    Integer startValue = null;
    Integer endValue = null;
    Integer minPos = null;
    Integer maxPos = null;
    boolean overlap = false;
    List<Integer> positions = extractPositiveIntegers(input);

    if (positions.size() > 0) {
        minPos = Collections.min(positions);
        maxPos = Collections.max(positions);
    }

    if (end != null && end.matches("\\d+")) {
        endValue = Integer.parseInt(end);
    }

    if (start != null && start.matches("\\d+")) {
        startValue = Integer.parseInt(start);
    }

    NumberRange range;

    if (startValue != null) {
        // if end value is not valid use start value as the end value
        if (endValue == null || endValue < startValue) {
            endValue = startValue;
        }

        range = new NumberRange(startValue, endValue);

        // check for an overlap
        if (range.containsNumber(minPos) || range.containsNumber(maxPos)) {
            overlap = true;
        }
    }

    // input can be a range value too!
    if (minPos != null && maxPos != null) {
        range = new NumberRange(minPos, maxPos);

        if (range.containsNumber(startValue) || range.containsNumber(endValue)) {
            overlap = true;
        }
    }

    return overlap;
}

From source file:com.navercorp.pinpoint.web.vo.stat.chart.DownSamplerTestBase.java

@Test
public void sampler_should_sample_correctly() {
    // Given/* w  w w.j a v a2 s.c o  m*/
    final List<T> samples = createSamples(RandomUtils.nextInt(1, 21));
    final T expectedMin = Collections.min(samples);
    final T expectedMax = Collections.max(samples);
    final double expectedMean = DoubleMath.mean(samples);
    // When
    T min = sampler.sampleMin(samples);
    T max = sampler.sampleMax(samples);
    double avg = sampler.sampleAvg(samples);
    double roundedAvg = sampler.sampleAvg(samples, NUM_DECIMALS_FOR_ROUNDED_AVG);
    // Then
    assertEquals(expectedMin, min);
    assertEquals(expectedMax, max);
    Assert.assertEquals(expectedMean, avg, DOUBLE_COMPARISON_DELTA);
    Assert.assertEquals(expectedMean, roundedAvg, NUM_DECIMALS_FOR_ROUNDED_AVG);
}

From source file:com.gmail.frogocomics.schematic.BiomeWorldV2Object.java

public static BiomeWorldV2Object load(File file) throws IOException {

    BufferedReader settingsReader;

    if (!file.exists()) {
        throw new FileNotFoundException();
    }//  w w w  . j  a va 2s. c om
    settingsReader = new BufferedReader(new FileReader(file));
    int lineNumber = 0;
    String thisLine;
    ArrayList<BiomeWorldObjectBlock> bo2Blocks = new ArrayList<>();

    while ((thisLine = settingsReader.readLine()) != null) {
        lineNumber++;
        if (Pattern.compile("[0-9]").matcher(thisLine.substring(0, 1)).matches()
                || thisLine.substring(0, 1).equalsIgnoreCase("-")) {
            //Example: -1,-1,5:18.4
            // x,z,y:id.data
            String[] location = thisLine.split(":")[0].split(",");
            String[] block = thisLine.split(":")[1].split("\\.");
            bo2Blocks.add(new BiomeWorldObjectBlock(Integer.parseInt(location[0]),
                    Integer.parseInt(location[2]), Integer.parseInt(location[1]), Short.parseShort(block[0]),
                    Byte.parseByte(block[1])));
        }
    }

    ArrayList<Integer> maxXMap = new ArrayList<>();
    ArrayList<Integer> maxYMap = new ArrayList<>();
    ArrayList<Integer> maxZMap = new ArrayList<>();
    for (BiomeWorldObjectBlock bo2 : bo2Blocks) {
        maxXMap.add(bo2.getX());
        maxYMap.add(bo2.getY());
        maxZMap.add(bo2.getZ());
    }

    int maxX = Collections.max(maxXMap);
    int maxY = Collections.max(maxYMap);
    int maxZ = Collections.max(maxZMap);
    int minX = Collections.min(maxXMap);
    int minY = Collections.min(maxYMap);
    int minZ = Collections.min(maxZMap);
    int differenceX = maxX - minX + 1;
    int differenceY = maxY - minY + 1;
    int differenceZ = maxZ - minZ + 1;

    HashMap<Integer, Set<BiomeWorldObjectBlock>> blocks = new HashMap<>();
    for (int i = 0; i < differenceY + 1; i++) {
        blocks.put(i, new HashSet<>());
    }

    for (BiomeWorldObjectBlock bo2 : bo2Blocks) {
        Set<BiomeWorldObjectBlock> a = blocks.get(bo2.getY() - minY);
        a.add(bo2);
        blocks.replace(bo2.getY(), a);
    }

    //System.out.println(differenceX + " " + differenceZ);
    SliceStack schematic = new SliceStack(differenceY, differenceX, differenceZ);

    for (Map.Entry<Integer, Set<BiomeWorldObjectBlock>> next : blocks.entrySet()) {
        Slice slice = new Slice(differenceX, differenceZ);
        for (BiomeWorldObjectBlock block : next.getValue()) {
            //System.out.println("Added block at " + String.valueOf(block.getX() - minX) + "," + String.valueOf(block.getZ() - minZ));
            slice.setBlock(block.getBlock(), block.getX() - minX, block.getZ() - minZ);
        }
        schematic.addSlice(slice);
    }
    //System.out.println(schematic.toString());

    return new BiomeWorldV2Object(schematic, FilenameUtils.getBaseName(file.getAbsolutePath()));
}

From source file:org.libreplan.business.workingday.IntraDayDate.java

public static IntraDayDate min(IntraDayDate... dates) {
    Validate.noNullElements(dates);
    return Collections.min(Arrays.asList(dates));
}

From source file:be.ugent.maf.cellmissy.gui.controller.analysis.doseresponse.area.AreaDRNormalizedController.java

/**
 * When changing view from input panel after creating new analysis group:
 * make dataset, do fitting and plot according to default parameters.
 *///from  ww w  .  j a  v  a 2  s. co m
@Override
public void initDRNormalizedData() {
    //set constrain combo boxes to standard setting: means
    dRNormalizedPlotPanel.getBottomComboBox().setSelectedIndex(0);
    dRNormalizedPlotPanel.getTopComboBox().setSelectedIndex(0);
    //set initial parameters
    dRNormalizedPlotPanel.getBottomTextField().setText(AnalysisUtils
            .roundTwoDecimals(Collections
                    .min(computeMeans(doseResponseController.getdRAnalysisGroup().getVelocitiesMap().values())))
            .toString());
    dRNormalizedPlotPanel.getTopTextField().setText(AnalysisUtils
            .roundTwoDecimals(Collections
                    .max(computeMeans(doseResponseController.getdRAnalysisGroup().getVelocitiesMap().values())))
            .toString());
    //LogTransform concentrations and perform initial normalization (mean values)
    dataToFit = prepareFittingData(doseResponseController.getdRAnalysisGroup());
    //create and set the table model for the top panel table (dependent on normalization)
    setTableModel(createTableModel(dataToFit));
    //Perform initial curve fitting (standard hillslope, no constraints)
    doseResponseController.performFitting(dataToFit, doseResponseController.getdRAnalysisGroup()
            .getDoseResponseAnalysisResults().getFittingResults(true), null, null);

}

From source file:ipLock.ProcessHandle.java

private static String determineJavaExecutablePath() {
    File javaHome = new File(System.getProperty("java.home"));

    Collection<File> files = FileUtils.listFiles(javaHome, new NameFileFilter("java"),
            new NameFileFilter("bin"));

    if (files.isEmpty()) {
        throw new RuntimeException("No java executable found at java home '" + javaHome + "'");
    }// ww w.j  a  v  a  2s .c o  m
    if (files.size() > 1) {
        throw new RuntimeException("Multiple java executables found at java home '" + javaHome + "': "
                + StringUtils.join(files, "; "));
    }

    return Collections.min(files).getAbsolutePath();
}

From source file:org.hibernate.shards.strategy.exit.AggregateExitOperation.java

public List<Object> apply(List<Object> results) {

    List<Object> nonNullResults = ExitOperationUtils.getNonNullList(results);

    switch (aggregate) {
    case MAX://from  ww w .  ja  v  a  2s  .c o m
        return Collections
                .singletonList((Object) Collections.max(ExitOperationUtils.getComparableList(nonNullResults)));
    case MIN:
        return Collections
                .singletonList((Object) Collections.min(ExitOperationUtils.getComparableList(nonNullResults)));
    case SUM:
        return Collections.<Object>singletonList(getSum(nonNullResults, fieldName));
    default:
        log.error("Aggregation Projection is unsupported: " + aggregate);
        throw new UnsupportedOperationException("Aggregation Projection is unsupported: " + aggregate);
    }
}

From source file:org.dkpro.tc.ml.report.util.ScatterplotRenderer.java

private double getMin(double[] values) {
    return Collections.min(Arrays.asList(ArrayUtils.toObject(values)));
}