Example usage for java.util Collections min

List of usage examples for java.util Collections min

Introduction

In this page you can find the example usage for java.util Collections min.

Prototype

@SuppressWarnings({ "unchecked", "rawtypes" })
public static <T> T min(Collection<? extends T> coll, Comparator<? super T> comp) 

Source Link

Document

Returns the minimum element of the given collection, according to the order induced by the specified comparator.

Usage

From source file:Main.java

public static <T> T min(Collection<? extends T> coll, Comparator<? super T> comp) {
    return Collections.min(coll, comp);
}

From source file:Main.java

public static <T extends Object> T min(final Collection<? extends T> collection,
        final Comparator<? super T> comparator) {
    return Collections.min(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 w  w.  j av a 2 s  .  c om*/
        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 ww . j a  va  2s  .  c om
        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:org.janusgraph.util.datastructures.PointInterval.java

@Override
public T getStart() {
    Preconditions.checkArgument(!isEmpty(), "There are no points in this interval");
    return (T) Collections.min(points, ComparableComparator.getInstance());
}

From source file:org.springside.modules.utils.collection.CollectionUtil.java

/**
 * ???/*from  w ww  . ja v  a  2s  . c  o m*/
 */
public static <T> T min(Collection<? extends T> coll, Comparator<? super T> comp) {
    return Collections.min(coll, comp);
}

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();
    }//from   www.j a va2s . c o 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:pl.rtshadow.jtriss.table.ColumnSet.java

private ColumnAccessor<?> findMinimalColumn() {
    return Collections.min(accessors, new Comparator<ColumnAccessor>() {
        @Override//from  ww  w  .j av  a  2  s  .c  o m
        public int compare(ColumnAccessor o1, ColumnAccessor o2) {
            return ObjectUtils.compare(o1.getSize(), o2.getSize());
        }
    });
}

From source file:de.hybris.platform.b2bacceleratorfacades.order.populators.ScheduledCartPopulator.java

/**
 * Returns the date of the first order placed chronologically.
 *//* w w  w . j a  va2 s. com*/
protected Date getFirstOrderDate(final Collection<OrderModel> orders) {
    Date firstOrderDate = null;

    if (CollectionUtils.isNotEmpty(orders)) {
        final OrderModel firstOrder = Collections.min(orders, new Comparator<OrderModel>() {
            @Override
            public int compare(final OrderModel orderModel1, final OrderModel orderModel2) {
                return orderModel1.getDate().compareTo(orderModel2.getDate());
            }
        });
        firstOrderDate = firstOrder.getDate();
    }

    return firstOrderDate;
}

From source file:edu.uiowa.icts.bluebutton.json.view.StatsFinder.java

public Double getMin() {
    List<Double> dList = this.getDoubleList();
    Double min = Collections.min(dList, new Comparator<Double>() {
        public int compare(Double d, Double d2) {
            if (d > d2) {
                return 1;
            } else if (d < d2) {
                return -1;
            }//from   w w w  .j ava 2s  . co m
            return 0;
        }
    });
    return min;
}