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:storybook.toolkit.DateUtil.java
public static void expandDatesToFuture(List<Date> dates, int count) { dates.removeAll(Collections.singletonList(null)); if (dates.isEmpty()) { return;// w w w . ja v a 2 s . c om } for (int i = 0; i < count; ++i) { Date lastDate = Collections.max(dates); if (lastDate == null) { return; } lastDate = new Date(DateUtils.addDays(lastDate, 1).getTime()); dates.add(lastDate); } }
From source file:org.dkpro.tc.ml.report.util.ScatterplotRenderer.java
private double getMax(double[] values) { return Collections.max(Arrays.asList(ArrayUtils.toObject(values))); }
From source file:uk.ac.diamond.scisoft.xpdf.operations.XPDFAzimuthalIntegrationOperation.java
@Override protected OperationData process(IDataset input, IMonitor monitor) throws OperationException { // get the XPDF metadata XPDFMetadata xMeta = input.getFirstMetadata(XPDFMetadata.class); // create the Operation that will do the processing AzimuthalPixelIntegrationOperation<XPDFAzimuthalIntegrationInternalModel> internalOperation = new AzimuthalPixelIntegrationOperation<XPDFAzimuthalIntegrationInternalModel>(); // create the fake model that will supply the parameters to the internal Operation XPDFAzimuthalIntegrationInternalModel internalModel = new XPDFAzimuthalIntegrationInternalModel( model.getAzimuthalRange(), model.getRadialRange(), model.isPixelSplitting(), model.getNumberOfBins());//from w w w . j a v a 2 s . c om internalOperation.setModel(internalModel); // Resize the data to be more like it was in the execute() method SliceFromSeriesMetadata ssm = getSliceSeriesMetadata(input); // Get the dimensions in the original data int[] dataDims = ssm.getDataDimensions(); int maxDimension = Collections.max(Arrays.asList(ArrayUtils.toObject(dataDims))); int[] newShape = new int[maxDimension + 1]; int[] oldShape = input.getShape(); // All elements of the new shape are 1 Arrays.fill(newShape, 1); // except those that are in the data for (int dim = 0; dim < oldShape.length; dim++) newShape[dataDims[dim]] = oldShape[dim]; IDataset reshapedInput = input.clone(); // The reshaped data is now (hopefully) the same shape as input was in this.execute() reshapedInput.resize(newShape); OperationData output = internalOperation.execute(reshapedInput, monitor); // Set the axis coordinate to q if (xMeta != null) { xMeta.getSample().getTrace().setAxisAngle(false); } output.getData().addMetadata(xMeta); return output; // OperationData superResult = super.process(input, monitor); // // // The downstream processing relies on metadata to tell if the axis is 2 or q // if (xMeta != null) { // // if (model.getAxisType() != XAxis.ANGLE) // xMeta.getSample().getTrace().setAxisAngle(false); // // superResult.getData().setMetadata(xMeta); // } // return superResult; }
From source file:org.libreplan.business.planner.limiting.entities.DateAndHour.java
public static DateAndHour max(DateAndHour... dates) { dates = (DateAndHour[]) ArrayUtils.removeElement(dates, null); return dates.length > 0 ? Collections.max(Arrays.asList(dates)) : null; }
From source file:org.kuali.kra.questionnaire.question.QuestionServiceImpl.java
/** * // ww w . j av a 2 s . c om * @see org.kuali.kra.questionnaire.question.QuestionService#getQuestionById(java.lang.String) */ @SuppressWarnings("unchecked") public Question getQuestionById(String questionId) { Question question = null; if (questionId != null) { Map<String, Object> fieldValues = new HashMap<String, Object>(); fieldValues.put(QUESTION_ID, questionId); Collection<Question> questions = businessObjectService.findMatching(Question.class, fieldValues); if (questions.size() > 0) { /* * Return the most recent approved question (i.e. the question version with the highest * sequence number that is approved/in the database). */ question = (Question) Collections.max(questions); } } return question; }
From source file:org.zkoss.ganttz.data.constraint.ConstraintOnComparableValues.java
private T max(T... values) { return Collections.max(Arrays.asList(values)); }
From source file:org.zkoss.ganttz.util.Interval.java
@SuppressWarnings("unchecked") public Interval coalesce(Interval otherInterval) { Validate.notNull(otherInterval);//from w w w . j a va 2 s . co m LocalDate minStart = Collections.min(asList(startInclusive, otherInterval.startInclusive)); LocalDate maxEnd = Collections.max(asList(endExclusive, otherInterval.endExclusive)); return new Interval(minStart, maxEnd); }
From source file:org.kuali.coeus.common.questionnaire.impl.question.QuestionServiceImpl.java
@Override @SuppressWarnings("unchecked") public Question getQuestionByQuestionSequenceId(Integer questionSeqId) { Question question = null;/*from ww w. java2 s. c om*/ if (questionSeqId != null) { Map<String, Object> fieldValues = new HashMap<String, Object>(); fieldValues.put(QuestionnaireConstants.QUESTION_SEQEQUENCE_ID, questionSeqId); Collection<Question> questions = businessObjectService.findMatching(Question.class, fieldValues); if (questions.size() > 0) { /* * Return the most recent approved question (i.e. the question version with the highest * sequence number that is approved/in the database). */ question = (Question) Collections.max(questions); } } return question; }
From source file:org.apache.lens.cube.parse.MaxCoveringFactResolver.java
@Override public void rewriteContext(CubeQueryContext cubeql) throws SemanticException { if (failOnPartialData) { // if fail on partial data is true, by the time this resolver starts, // all candidate fact sets are covering full time range. We can avoid // redundant computation. return;/*from w w w. j av a2s. c o m*/ } if (cubeql.getCube() == null || cubeql.getCandidateFactSets().size() <= 1) { // nothing to prune. return; } // For each part column, which candidate fact sets are covering how much amount. // Later, we'll maximize coverage for each queried part column. Map<String, Map<Set<CandidateFact>, Long>> partCountsPerPartCol = Maps.newHashMap(); for (Set<CandidateFact> facts : cubeql.getCandidateFactSets()) { for (Map.Entry<String, Long> entry : getTimeCoveredForEachPartCol(facts).entrySet()) { if (!partCountsPerPartCol.containsKey(entry.getKey())) { partCountsPerPartCol.put(entry.getKey(), Maps.<Set<CandidateFact>, Long>newHashMap()); } partCountsPerPartCol.get(entry.getKey()).put(facts, entry.getValue()); } } // for each queried partition, prune fact sets that are covering less range than max for (String partColQueried : cubeql.getPartitionColumnsQueried()) { if (partCountsPerPartCol.get(partColQueried) != null) { long maxTimeCovered = Collections.max(partCountsPerPartCol.get(partColQueried).values()); TimeCovered timeCovered = new TimeCovered(maxTimeCovered); Iterator<Set<CandidateFact>> iter = cubeql.getCandidateFactSets().iterator(); while (iter.hasNext()) { Set<CandidateFact> facts = iter.next(); Long timeCoveredLong = partCountsPerPartCol.get(partColQueried).get(facts); if (timeCoveredLong == null) { timeCoveredLong = 0L; } if (timeCoveredLong < maxTimeCovered) { LOG.info("Not considering facts:" + facts + " from candidate fact tables as it covers less time than the max" + " for partition column: " + partColQueried + " which is: " + timeCovered); iter.remove(); } } } } cubeql.pruneCandidateFactWithCandidateSet(CandidateTablePruneCause.lessData(null)); }
From source file:es.ehu.si.ixa.pipe.nerc.train.InputOutputUtils.java
public static List<List<Integer>> getBestIterations(Map<List<Integer>, Double> results, List<List<Integer>> allParams) throws IOException { StringBuffer sb = new StringBuffer(); Double bestResult = (Collections.max(results.values())); for (Map.Entry<List<Integer>, Double> result1 : results.entrySet()) { if (result1.getValue().compareTo(bestResult) == 0) { allParams.add(result1.getKey()); sb.append("Best results: ").append(result1.getKey()).append(" ").append(result1.getValue()) .append("\n"); System.out.println("Results: " + result1.getKey() + " " + result1.getValue()); }//from w w w .j a v a 2 s. co m } FileUtils.writeStringToFile(new File("best-results.txt"), sb.toString(), "UTF-8"); System.out.println("Best F via cross evaluation: " + bestResult); System.out.println("All Params " + allParams.size()); return allParams; }