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)
| 586 | * @since 11.0 |
| 587 | */ |
| 588 | @CanIgnoreReturnValue // TODO(kak): Consider removing this |
| 589 | public <E extends T> E max(Iterator<E> iterator) { |
| 590 | // let this throw NoSuchElementException as necessary |
| 591 | E maxSoFar = iterator.next(); |
| 592 | |
| 593 | while (iterator.hasNext()) { |
| 594 | maxSoFar = max(maxSoFar, iterator.next()); |
| 595 | } |
| 596 | |
| 597 | return maxSoFar; |
| 598 | } |
| 599 | |
| 600 | /** |
| 601 | * Returns the greatest of the specified values according to this ordering. If |
no test coverage detected