maxBy<R extends Comparable> method
E?
maxBy<R extends Comparable>(
- R f(
- E e
Implementation
E? maxBy<R extends Comparable>(R f(E e)) {
if (this.isEmpty) return null;
E result = elementAt(0);
R max = f(result);
forEach((element) {
R r = f(element);
int i = max.compareTo(r);
if (i < 0) {
max = r;
result = element;
}
});
return result;
}