org.psjava.formula.MaxInIterable Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of psjava Show documentation
Show all versions of psjava Show documentation
Problem Solving Library for Java
The newest version!
package org.psjava.formula;
import java.util.Comparator;
import org.psjava.util.AssertStatus;
public class MaxInIterable {
public static T max(Iterable iterable, Comparator comp) {
T max = null;
for (T a : iterable)
if (max == null || comp.compare(max, a) < 0)
max = a;
AssertStatus.assertTrue(max != null, "Empty Iterable");
return max;
}
private MaxInIterable() {
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy