List of usage examples for java.util Collections min
@SuppressWarnings({ "unchecked", "rawtypes" }) public static <T> T min(Collection<? extends T> coll, Comparator<? super T> comp)
From source file:net.sourceforge.fenixedu.domain.ExecutionDegree.java
public boolean isFirstYear() { final Collection<ExecutionDegree> executionDegrees = this.getDegreeCurricularPlan() .getExecutionDegreesSet();//from w w w. j a v a 2s . c om return this == Collections.min(executionDegrees, EXECUTION_DEGREE_COMPARATORY_BY_YEAR); }
From source file:org.squashtest.tm.domain.campaign.Campaign.java
private Iteration getFirstIteration() { if (getIterations().isEmpty()) { return null; } else {/*from w w w . j a v a 2 s . c o m*/ return Collections.min(getIterations(), CascadingAutoDateComparatorBuilder.buildIterationActualStartOrder()); } }
From source file:org.apache.sysml.hops.codegen.template.CPlanMemoTable.java
public MemoTableEntry getBest(long hopID, TemplateType pref) { List<MemoTableEntry> tmp = get(hopID); if (tmp == null || tmp.isEmpty()) return null; //single plan per type, get plan w/ best rank in preferred order return Collections.min(tmp, Comparator.comparing(p -> (p.type == pref) ? -p.countPlanRefs() : p.type.getRank() + 1)); }
From source file:norbert.mynemo.core.selection.RecommenderSelector.java
/** * Returns the best recommender for the target user among the given recommenders. The given * algorithms are evaluated, then the minimum evaluation computed with the * {@link EvaluationComparator} class is returned. * * <p>/*from w w w . ja v a2 s.c o m*/ * The evaluations are compared with the given metric. The evaluations with a coverage lower than * the given one are ignored. */ public Optional<RecommenderEvaluation> selectAmong(List<RecommenderType> types, double minimumCoverage) throws TasteException { checkNotNull(types); checkArgument(!types.isEmpty(), "The algorithm list must contain at least one algorithm."); checkArgument(0 <= minimumCoverage && minimumCoverage <= 1, "The minimum coverage must not be" + " lesser than 0 or greater than 1."); List<RecommenderEvaluation> evaluations = evaluateAll(types, minimumCoverage); removeUnallowedCoverage(evaluations, minimumCoverage); retainBestEvaluations(evaluations); Optional<RecommenderEvaluation> result; if (evaluations.isEmpty()) { result = Optional.absent(); } else { result = Optional.of(Collections.min(evaluations, new EvaluationComparator(metric))); } return result; }
From source file:org.apache.sysml.hops.codegen.template.CPlanMemoTable.java
public MemoTableEntry getBest(long hopID, TemplateType pref1, TemplateType pref2) { List<MemoTableEntry> tmp = get(hopID); if (tmp == null || tmp.isEmpty()) return null; //single plan per type, get plan w/ best rank in preferred order return Collections.min(tmp, Comparator.comparing(p -> (p.type == pref1) ? -p.countPlanRefs() - 4 : (p.type == pref2) ? -p.countPlanRefs() : p.type.getRank() + 1)); }
From source file:com.example.android.camera2basic.Fragment.Camera2BasicFragment.java
/** * Given {@code choices} of {@code Size}s supported by a camera, choose the smallest one that * is at least as large as the respective texture view size, and that is at most as large as the * respective max size, and whose aspect ratio matches with the specified value. If such size * doesn't exist, choose the largest one that is at most as large as the respective max size, * and whose aspect ratio matches with the specified value. * * @param choices The list of sizes that the camera supports for the intended output * class//from ww w. jav a 2 s.c om * @param textureViewWidth The width of the texture view relative to sensor coordinate * @param textureViewHeight The height of the texture view relative to sensor coordinate * @param maxWidth The maximum width that can be chosen * @param maxHeight The maximum height that can be chosen * @param aspectRatio The aspect ratio * @return The optimal {@code Size}, or an arbitrary one if none were big enough */ private static Size chooseOptimalSize(Size[] choices, int textureViewWidth, int textureViewHeight, int maxWidth, int maxHeight, Size aspectRatio) { // Collect the supported resolutions that are at least as big as the preview Surface List<Size> bigEnough = new ArrayList<>(); // Collect the supported resolutions that are smaller than the preview Surface List<Size> notBigEnough = new ArrayList<>(); int w = aspectRatio.getWidth(); int h = aspectRatio.getHeight(); for (Size option : choices) { if (option.getWidth() <= maxWidth && option.getHeight() <= maxHeight && option.getHeight() == option.getWidth() * h / w) { if (option.getWidth() >= textureViewWidth && option.getHeight() >= textureViewHeight) { bigEnough.add(option); } else { notBigEnough.add(option); } } } // Pick the smallest of those big enough. If there is no one big enough, pick the // largest of those not big enough. if (bigEnough.size() > 0) { return Collections.min(bigEnough, new CompareSizesByArea()); } else if (notBigEnough.size() > 0) { return Collections.max(notBigEnough, new CompareSizesByArea()); } else { Log.e(TAG, "Couldn't find any suitable preview size"); // Log.d(TAG,choices[0].getWidth()+" size "+choices[0].getHeight()); return choices[0]; } }
From source file:org.odk.collect.android.fragments.Camera2Fragment.java
/** * Given {@code choices} of {@code Size}s supported by a camera, choose the smallest one that * is at least as large as the respective texture view size, and that is at most as large as the * respective max size, and whose aspect ratio matches with the specified value. If such size * doesn't exist, choose the largest one that is at most as large as the respective max size, * and whose aspect ratio matches with the specified value. * * @param choices The list of sizes that the camera supports for the intended output * class//w w w .j av a2 s . c o m * @param textureViewWidth The width of the texture view relative to sensor coordinate * @param textureViewHeight The height of the texture view relative to sensor coordinate * @param maxWidth The maximum width that can be chosen * @param maxHeight The maximum height that can be chosen * @param aspectRatio The aspect ratio * @return The optimal {@code Size}, or an arbitrary one if none were big enough */ private static Size chooseOptimalSize(Size[] choices, int textureViewWidth, int textureViewHeight, int maxWidth, int maxHeight, Size aspectRatio) { // Collect the supported resolutions that are at least as big as the preview Surface List<Size> bigEnough = new ArrayList<>(); // Collect the supported resolutions that are smaller than the preview Surface List<Size> notBigEnough = new ArrayList<>(); int w = aspectRatio.getWidth(); int h = aspectRatio.getHeight(); for (Size option : choices) { if (option.getWidth() <= maxWidth && option.getHeight() <= maxHeight && option.getHeight() == option.getWidth() * h / w) { if (option.getWidth() >= textureViewWidth && option.getHeight() >= textureViewHeight) { bigEnough.add(option); } else { notBigEnough.add(option); } } } // Pick the smallest of those big enough. If there is no one big enough, pick the // largest of those not big enough. if (bigEnough.size() > 0) { return Collections.min(bigEnough, new CompareSizesByArea()); } else if (notBigEnough.size() > 0) { return Collections.max(notBigEnough, new CompareSizesByArea()); } else { return choices[0]; } }
From source file:cliq.com.cliqgram.fragments.CameraFragment.java
/** * Given {@code choices} of {@code Size}s supported by a camera, chooses the smallest one whose * width and height are at least as large as the respective requested values, and whose aspect * ratio matches with the specified value. * * @param choices The list of sizes that the camera supports for the intended output class * @param width The minimum desired width * @param height The minimum desired height * @param aspectRatio The aspect ratio//from w w w .j av a2s . com * @return The optimal {@code Size}, or an arbitrary one if none were big enough */ private static Size chooseOptimalSize(Size[] choices, int width, int height, Size aspectRatio) { // Collect the supported resolutions that are at least as big as the preview Surface List<Size> bigEnough = new ArrayList<>(); int w = aspectRatio.getWidth(); int h = aspectRatio.getHeight(); for (Size option : choices) { if (option.getHeight() == option.getWidth() * h / w && option.getWidth() >= width && option.getHeight() >= height) { bigEnough.add(option); } } // Pick the smallest of those, assuming we found any if (bigEnough.size() > 0) { return Collections.min(bigEnough, new CompareSizesByArea()); } else { Log.e(TAG, "Couldn't find any suitable preview size"); return choices[0]; } }
From source file:camera2basic.Camera2BasicFragment.java
/** * Given {@code choices} of {@code Size}s supported by a camera, choose the smallest one that * is at least as large as the respective texture view size, and that is at most as large as the * respective max size, and whose aspect ratio matches with the specified value. If such size * doesn't exist, choose the largest one that is at most as large as the respective max size, * and whose aspect ratio matches with the specified value. * * @param choices The list of sizes that the camera supports for the intended output * class/*from w w w . j a va2 s . c o m*/ * @param textureViewWidth The width of the texture view relative to sensor coordinate * @param textureViewHeight The height of the texture view relative to sensor coordinate * @param maxWidth The maximum width that can be chosen * @param maxHeight The maximum height that can be chosen * @param aspectRatio The aspect ratio * @return The optimal {@code Size}, or an arbitrary one if none were big enough */ private static Size chooseOptimalSize(Size[] choices, int textureViewWidth, int textureViewHeight, int maxWidth, int maxHeight, Size aspectRatio) { // Collect the supported resolutions that are at least as big as the preview Surface List<Size> bigEnough = new ArrayList<>(); // Collect the supported resolutions that are smaller than the preview Surface List<Size> notBigEnough = new ArrayList<>(); int w = aspectRatio.getWidth(); int h = aspectRatio.getHeight(); for (Size option : choices) { if (option.getWidth() <= maxWidth && option.getHeight() <= maxHeight && option.getHeight() == option.getWidth() * h / w) { if (option.getWidth() >= textureViewWidth && option.getHeight() >= textureViewHeight) { bigEnough.add(option); } else { notBigEnough.add(option); } } } // Pick the smallest of those big enough. If there is no one big enough, pick the // largest of those not big enough. if (bigEnough.size() > 0) { return Collections.min(bigEnough, new CompareSizesByArea()); } else if (notBigEnough.size() > 0) { return Collections.max(notBigEnough, new CompareSizesByArea()); } else { Log.e(TAG, "Couldn't find any suitable preview size"); return choices[0]; } }
From source file:com.example.joshf.conc.CameraFragment.java
private static Size chooseOptimalSize(Size[] choices, int textureViewWidth, int textureViewHeight, int maxWidth, int maxHeight, Size aspectRatio) { // Collect the supported resolutions that are at least as big as the preview Surface List<Size> bigEnough = new ArrayList<>(); // Collect the supported resolutions that are smaller than the preview Surface List<Size> notBigEnough = new ArrayList<>(); int w = aspectRatio.getWidth(); int h = aspectRatio.getHeight(); for (Size option : choices) { if (option.getWidth() <= maxWidth && option.getHeight() <= maxHeight && option.getHeight() == option.getWidth() * h / w) { if (option.getWidth() >= textureViewWidth && option.getHeight() >= textureViewHeight) { bigEnough.add(option);//from ww w . j ava 2 s .com } else { notBigEnough.add(option); } } } // Pick the smallest of those big enough. If there is no one big enough, pick the // largest of those not big enough. if (bigEnough.size() > 0) { return Collections.min(bigEnough, new CompareSizesByArea()); } else if (notBigEnough.size() > 0) { return Collections.max(notBigEnough, new CompareSizesByArea()); } else { Log.e(TAG, "Couldn't find any suitable preview size"); return choices[0]; } }