public static <T> T max(final Iterator<T> iterator, Comparator<? super T> comparator) {
		if (comparator == null)
			throw new NullPointerException("comparator");
		T max = iterator.next();
		while (iterator.hasNext()) {
			T element = iterator.next();
			max = comparator.compare(max, element) >= 0 ? max : element;
		}
		return max;
	}
public static < T > T max ( final Iterator < T > iterator , Comparator < ? super T > comparator ) { if ( comparator == null ) throw new NullPointerException ( "comparator" ) ; T max = iterator . next ( ) ; while ( iterator . hasNext ( ) ) { T element = iterator . next ( ) ; max = comparator . compare ( max , element ) >= 0 ? max : element ; } return max ; }
Finds the maximum element according to <code>comparator</code>. If there are several maxima, the first one will
be returned.

@param iterator
the elements to find the maximum of. May not be <code>null</code>.
@param comparator
the comparison function. May not be <code>null</code>.
@return the maximum
@throws NoSuchElementException
if the iterator is empty
@since 2.7