List of usage examples for java.util Collections min
public static <T extends Object & Comparable<? super T>> T min(Collection<? extends T> coll)
From source file:org.libreplan.web.limitingresources.GapsMergeSort.java
public static List<GapOnQueue> sort(List<List<GapOnQueue>> orderedListsOfGaps) { List<GapOnQueue> result = new ArrayList<>(); if (orderedListsOfGaps.isEmpty()) { return result; }/*from w w w . ja v a2 s . co m*/ if (orderedListsOfGaps.size() == 1) { return orderedListsOfGaps.get(0); } List<CurrentGap> currentGaps = CurrentGap.convert(iteratorsFor(orderedListsOfGaps)); CurrentGap min = Collections.min(currentGaps); while (!currentGaps.isEmpty() && !min.hasFinished()) { result.add(min.consume()); if (min.hasFinished()) { currentGaps.remove(min); if (!currentGaps.isEmpty()) { min = Collections.min(currentGaps); } } } return result; }
From source file:jav.correctionBackend.parser.WagnerFischer.java
private int getMin(int i, int j) { assert (i > 0); assert (j > 0); assert ((i - 1) < ocr.size()); assert ((j - 1) < gt.size()); if (ocr.get(i - 1).getChar() == gt.get(j - 1).getChar()) { return matrix[i - 1][j - 1]; } else {// w ww . j a va2 s.co m int[] tmp = { matrix[i - 1][j - 1] + 1, matrix[i - 1][j] + 1, matrix[i][j - 1] + 1 }; return Collections.min(Arrays.asList(ArrayUtils.toObject(tmp))); } }
From source file:org.wallerlab.yoink.molecular.service.calculator.SortedDistancesCalculator.java
private Map<Molecule, Double> loopOverMolecules(Set<Molecule> molecules, Coord centerCoord) { Map<Molecule, Double> distances = new HashMap<Molecule, Double>(); for (Molecule molecule : molecules) { List<Double> atomDistances = new ArrayList<Double>(); for (Atom atom : molecule.getAtoms()) { double distance = distanceCalculator.calculate(centerCoord, atom); atomDistances.add(distance); }//from ww w . j a v a 2s .c o m // sort the distances for given atoms in a molecule double distanceMin = Collections.min(atomDistances); // store the molecule with its closest atom distances.put(molecule, distanceMin); } return distances; }
From source file:Simulator.java
private double GetDistanceToClosestFence(Coordinate curLoc, ArrayList<MapMarker> fenceLocs) { ArrayList<Double> distances = new ArrayList<>(); for (MapMarker fence : fenceLocs) { distances.add(getDistance(curLoc, fence.getCoordinate())); }// www . j av a 2 s . c o m return Collections.min(distances); }
From source file:org.zkoss.ganttz.data.constraint.ConstraintOnComparableValues.java
private T min(T... values) { return Collections.min(Arrays.asList(values)); }
From source file:io.appium.uiautomator2.utils.AlertHelpers.java
@Nullable private static UiObject2 getRegularAlertButton(AlertAction action, @Nullable String buttonLabel) { final Map<String, UiObject2> alertButtonsMapping = new HashMap<>(); final List<Integer> buttonIndexes = new ArrayList<>(); for (final UiObject2 button : getUiDevice().findObjects(By.res(regularAlertButtonResIdPattern))) { final String resId = button.getResourceName(); alertButtonsMapping.put(resId, button); buttonIndexes.add(Integer.parseInt(resId.substring(regularAlertButtonResIdPrefix.length()))); }//from w w w .j ava 2 s . c om if (alertButtonsMapping.isEmpty()) { return null; } Log.d(TAG, String.format("Found %d buttons on the alert", alertButtonsMapping.size())); if (buttonLabel == null) { final int minIdx = Collections.min(buttonIndexes); return action == AlertAction.ACCEPT ? alertButtonsMapping.get(buttonResIdByIdx(minIdx)) : alertButtonsMapping .get(buttonResIdByIdx(alertButtonsMapping.size() > 1 ? minIdx + 1 : minIdx)); } return filterButtonByLabel(alertButtonsMapping.values(), buttonLabel); }
From source file:org.mrgeo.aggregators.MinAvgPairAggregator.java
@Override public float aggregate(float[] values, float nodata) { boolean data0 = Float.compare(values[0], nodata) != 0; boolean data1 = Float.compare(values[1], nodata) != 0; boolean data2 = Float.compare(values[2], nodata) != 0; boolean data3 = Float.compare(values[3], nodata) != 0; Collection<Float> averages = new ArrayList<Float>(); if (data0 && data1) averages.add(Float.valueOf((values[0] + values[1]) / 2)); if (data0 && data2) averages.add(Float.valueOf((values[0] + values[2]) / 2)); if (data0 && data3) averages.add(Float.valueOf((values[0] + values[3]) / 2)); if (data1 && data2) averages.add(Float.valueOf((values[1] + values[2]) / 2)); if (data1 && data3) averages.add(Float.valueOf((values[1] + values[3]) / 2)); if (data2 && data3) averages.add(Float.valueOf((values[2] + values[3]) / 2)); return (averages.isEmpty()) ? nodata : Collections.min(averages).floatValue(); }
From source file:org.zkoss.ganttz.util.Interval.java
@SuppressWarnings("unchecked") public Interval coalesce(Interval otherInterval) { Validate.notNull(otherInterval);/*from w w w . ja va2 s . c o 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.libreplan.business.planner.limiting.entities.DateAndHour.java
public static DateAndHour min(DateAndHour... dates) { dates = (DateAndHour[]) ArrayUtils.removeElement(dates, null); return dates.length > 0 ? Collections.min(Arrays.asList(dates)) : null; }
From source file:com.compomics.cell_coord.computation.impl.TrackOperatorImpl.java
@Override public void computeCoordinatesRanges(Track track) { Double[][] coordinates = track.getCoordinates(); Double[][] transpCoord = ComputationUtils.transpose2DArray(coordinates); List<Double> xCoordAsList = Arrays.asList(transpCoord[0]); List<Double> yCoordAsList = Arrays.asList(transpCoord[1]); Double xMin = Collections.min(xCoordAsList); Double xMax = Collections.max(xCoordAsList); Double yMin = Collections.min(yCoordAsList); Double yMax = Collections.max(yCoordAsList); Double[][] coordinatesRanges = new Double[][] { { xMin, xMax }, { yMin, yMax } }; track.setCoordinateRanges(coordinatesRanges); track.setxNetDisplacement(xMax - xMin); track.setyNetDisplacement(yMax - yMin); }