List of usage examples for java.util Collections max
public static <T extends Object & Comparable<? super T>> T max(Collection<? extends T> coll)
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 w ww.java 2 s.co m * 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:org.jbpm.kie.services.api.DeploymentIdResolver.java
public static String findLatest(Collection<String> deploymentIds) { List<ComparableVersion> comparableVersions = new ArrayList<ComparableVersion>(); Map<String, String> versionToIdentifier = new HashMap<String, String>(); for (String deploymentId : deploymentIds) { GAVInfo gav = new GAVInfo(deploymentId); comparableVersions.add(new ComparableVersion(gav.getVersion())); versionToIdentifier.put(gav.getVersion(), deploymentId); }//from w w w . j a va2 s . c o m ComparableVersion latest = Collections.max(comparableVersions); return versionToIdentifier.get(latest.toString()); }
From source file:br.ufpe.cin.emergo.instrument.bitrep.BitVectorFeatureRep.java
public void computeBitVector() { int highestId = atoms.isEmpty() ? 1 : ((Integer) Collections.max(this.atoms.values())) << 1; this.bits = new BitVector(highestId); for (int index = 0; index < highestId; index++) { if ((this.id & index) == index) { bits.set(index);//from w w w.j av a2 s. co m } } return; }
From source file:com.navercorp.pinpoint.web.vo.stat.chart.DownSamplerTestBase.java
@Test public void sampler_should_sample_correctly() { // Given//from w w w. j a v a 2s . 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: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());/*from ww w . j av a2 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:org.duracloud.id.generator.ldap.impl.LdapImpl.java
@Override public int maxRightsId() { String base = "ou=rights"; String filter = "objectClass=x-idp-rights"; List<Integer> ids = getIds(base, filter); return ids.isEmpty() ? 0 : Collections.max(ids); }
From source file:org.spotter.ext.detection.highmessaging.analyze.Analyzer.java
protected List<Double> normalize(List<Double> values) { double max = Collections.max(values); return normalize(values, max); }
From source file:org.libreplan.business.workingday.IntraDayDate.java
public static IntraDayDate max(IntraDayDate... dates) { Validate.noNullElements(dates); return Collections.max(Arrays.asList(dates)); }
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 w w w . jav 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: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 www. j av a2 s .c o 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); }