List of usage examples for java.util Collections max
@SuppressWarnings({ "unchecked", "rawtypes" }) public static <T> T max(Collection<? extends T> coll, Comparator<? super T> comp)
From source file:Main.java
public static <T> T max(Collection<? extends T> coll, Comparator<? super T> comp) { return Collections.max(coll, comp); }
From source file:Main.java
public static <T extends Object> T max(final Collection<? extends T> collection, final Comparator<? super T> comparator) { return Collections.max(collection, comparator); }
From source file:es.udc.gii.common.eaf.stoptest.TolFunHistStopTest.java
@Override public boolean isReach(EvolutionaryAlgorithm algorithm) { //Fitness value to check in this stop test: double worst_history, best_history; if (algorithm.getGenerations() > algorithm.getFitnessHistory().size()) { worst_history = ((Individual) Collections.max(algorithm.getFitnessHistory(), algorithm.getComparator())) .getFitness();/*w ww . jav a2 s .c o m*/ best_history = ((Individual) Collections.min(algorithm.getFitnessHistory(), algorithm.getComparator())) .getFitness(); if (Math.abs(worst_history - best_history) <= this.tol_fun_hist) { return true; } } return false; }
From source file:es.udc.gii.common.eaf.stoptest.TolFunStopTest.java
@Override public boolean isReach(EvolutionaryAlgorithm algorithm) { //Fitness value to check in this stop test: double worst_history, best_history, best_fitness, worst_fitness; if (algorithm.getFitnessHistory() != null && algorithm.getFitnessHistory().size() > 0) { worst_history = ((Individual) Collections.max(algorithm.getFitnessHistory(), algorithm.getComparator())) .getFitness();//w w w .ja va 2 s . com best_history = ((Individual) Collections.min(algorithm.getFitnessHistory(), algorithm.getComparator())) .getFitness(); best_fitness = algorithm.getBestIndividual().getFitness(); worst_fitness = algorithm.getWorstIndividual().getFitness(); if ((algorithm.getGenerations() > 1) && (Math.abs( Math.max(worst_history, worst_fitness) - Math.min(best_history, best_fitness))) <= tol_fun) { return true; } } return false; }
From source file:net.sourceforge.fenixedu.domain.reimbursementGuide.ReimbursementGuide.java
public static Integer generateReimbursementGuideNumber() { Collection<ReimbursementGuide> reimbursementGuides = Bennu.getInstance().getReimbursementGuidesSet(); return (reimbursementGuides.isEmpty()) ? Integer.valueOf(1) : Collections.max(reimbursementGuides, NUMBER_COMPARATOR).getNumber() + 1; }
From source file:org.janusgraph.util.datastructures.PointInterval.java
@Override public T getEnd() { Preconditions.checkArgument(!isEmpty(), "There are no points in this interval"); return (T) Collections.max(points, ComparableComparator.getInstance()); }
From source file:net.sourceforge.fenixedu.domain.candidacy.Candidacy.java
public final Integer createCandidacyNumber() { if (Bennu.getInstance().getCandidaciesSet().size() == 0) { return Integer.valueOf(1); }/*from www .j a v a 2s .c o m*/ Candidacy candidacy = Collections.max(Bennu.getInstance().getCandidaciesSet(), new BeanComparator("number")); return candidacy.getNumber() + 1; }
From source file:org.libreplan.business.planner.chart.ContiguousDaysLine.java
public static ContiguousDaysLine<List<DayAssignment>> byDay(Collection<? extends DayAssignment> assignments) { if (assignments.isEmpty()) { return invalid(); }// w w w .java2 s .co m DayAssignment min = Collections.min(assignments, DayAssignment.byDayComparator()); DayAssignment max = Collections.max(assignments, DayAssignment.byDayComparator()); ContiguousDaysLine<List<DayAssignment>> result = create(min.getDay(), max.getDay().plusDays(1)); result.transformInSitu(new IValueTransformer<List<DayAssignment>, List<DayAssignment>>() { @Override public List<DayAssignment> transform(LocalDate day, List<DayAssignment> previousValue) { return new LinkedList<DayAssignment>(); } }); for (DayAssignment each : assignments) { result.get(each.getDay()).add(each); } return result; }
From source file:com.daugherty.e2c.domain.Supplier.java
public Membership getMembership() { if (memberships.isEmpty()) { return null; } else {/*from w w w . j a v a 2 s .c om*/ Date now = new Date(); for (Membership membership : memberships) { if (membership.getEffectiveDate().getTime() <= now.getTime() && now.getTime() <= membership.getExpirationDate().getTime()) { return membership; } } } return Collections.max(memberships, new MembershipExpirationDateComparator()); }
From source file:org.springside.modules.utils.collection.CollectionUtil.java
/** * ??//from w w w. ja v a 2 s. co m */ public static <T> T max(Collection<? extends T> coll, Comparator<? super T> comp) { return Collections.max(coll, comp); }