MCPcopy Create free account
hub / github.com/davidgiven/luje / max

Method max

lib/java/util/Collections.java:1661–1672  ·  view source on GitHub ↗

Searches the specified collection for the maximum element. @param collection the collection to search. @return the maximum element in the Collection. @throws ClassCastException when an element in the collection does not implement Comparable or elements can

(
            Collection<? extends T> collection)

Source from the content-addressed store, hash-verified

1659 * other.
1660 */
1661 public static <T extends Object & Comparable<? super T>> T max(
1662 Collection<? extends T> collection) {
1663 Iterator<? extends T> it = collection.iterator();
1664 T max = it.next();
1665 while (it.hasNext()) {
1666 T next = it.next();
1667 if (max.compareTo(next) < 0) {
1668 max = next;
1669 }
1670 }
1671 return max;
1672 }
1673
1674 /**
1675 * Searches the specified collection for the maximum element using the

Callers

nothing calls this directly

Calls 5

iteratorMethod · 0.65
nextMethod · 0.65
hasNextMethod · 0.65
compareToMethod · 0.65
compareMethod · 0.65

Tested by

no test coverage detected