Returns the greatest of the specified values according to this ordering. If there are multiple greatest values, the first of those is returned. The iterator will be left exhausted: its hasNext() method will return false. @param iterator the iterator whose maximum element is to be de
(Iterator<E> iterator)
| 601 | */ |
| 602 | |
| 603 | @CanIgnoreReturnValue // TODO(kak): Consider removing this |
| 604 | public <E extends T> E max(Iterator<E> iterator) { |
| 605 | // let this throw NoSuchElementException as necessary |
| 606 | E maxSoFar = iterator.next(); |
| 607 | while (iterator.hasNext()) { |
| 608 | maxSoFar = max(maxSoFar, iterator.next()); |
| 609 | } |
| 610 | return maxSoFar; |
| 611 | } |
| 612 | |
| 613 | /** |
| 614 | * Returns the greatest of the specified values according to this ordering. If |