/** * @deprecated Use the Iterable version of max instead * @see #max(Iterable, Closure) * @since 1.0 */ @Deprecated public static <T> T max(Collection<T> self, Closure closure) { return max((Iterable<T>) self, closure); }
/** * @deprecated Use the Iterable version of max instead * @see #max(Iterable, Comparator) * @since 1.0 */ @Deprecated public static <T> T max(Collection<T> self, Comparator<T> comparator) { return max((Iterable<T>)self, comparator); }
/** * Selects the maximum value found from the Iterator using the given comparator. * * @param self an Iterator * @param comparator a Comparator * @return the maximum value * @since 1.5.5 */ public static <T> T max(Iterator<T> self, Comparator<T> comparator) { return max((Iterable<T>)toList(self), comparator); }
/** * Adds max() method to Iterator objects. The iterator will become * exhausted of elements after determining the maximum value. * * @param self an Iterator * @return the maximum value * @see groovy.util.GroovyCollections#max(java.util.Collection) * @since 1.5.5 */ public static <T> T max(Iterator<T> self) { return max((Iterable<T>)toList(self)); }
/** * Selects the maximum value found from the Object array using the given comparator. * * @param self an array * @param comparator a Comparator * @return the maximum value * @since 1.5.5 */ public static <T> T max(T[] self, Comparator<T> comparator) { return max((Iterable<T>)toList(self), comparator); }
/** * Adds max() method to Object arrays. * * @param self an array * @return the maximum value * @see #max(java.util.Collection) * @since 1.5.5 */ public static <T> T max(T[] self) { return max((Iterable<T>)toList(self)); }
return max((Iterable<Map.Entry<K, V>>)self.entrySet(), closure);
public void testMaxMap() { Map.Entry<String, Integer> lionEntry = null; for (Map.Entry<String, Integer> entry : zoo.entrySet()) { if (entry.getKey().equals("Lions")) lionEntry = entry; } assertEquals(lionEntry, max(zoo.entrySet(), new Closure<Integer>(null) { public Integer doCall(Map.Entry<String, Integer> e) { return e.getKey().length() * e.getValue(); } })); }
/** * Selects the maximum value found from the Iterator * using the closure to determine the correct ordering. * The iterator will become exhausted of elements after this operation. * <p> * If the closure has two parameters * it is used like a traditional Comparator. I.e. it should compare * its two parameters for order, returning a negative integer, * zero, or a positive integer when the first parameter is less than, * equal to, or greater than the second respectively. Otherwise, * the Closure is assumed to take a single parameter and return a * Comparable (typically an Integer) which is then used for * further comparison. * * @param self an Iterator * @param closure a Closure used to determine the correct ordering * @return the maximum value * @see #max(java.util.Collection, groovy.lang.Closure) * @since 1.5.5 */ public static <T> T max(Iterator<T> self, @ClosureParams(value=FromString.class, options={"T","T,T"}) Closure closure) { return max((Iterable<T>)toList(self), closure); }
/** * Selects the maximum value found from the Object array * using the closure to determine the correct ordering. * <p> * If the closure has two parameters * it is used like a traditional Comparator. I.e. it should compare * its two parameters for order, returning a negative integer, * zero, or a positive integer when the first parameter is less than, * equal to, or greater than the second respectively. Otherwise, * the Closure is assumed to take a single parameter and return a * Comparable (typically an Integer) which is then used for * further comparison. * * @param self an array * @param closure a Closure used to determine the correct ordering * @return the maximum value * @see #max(java.util.Collection, groovy.lang.Closure) * @since 1.5.5 */ public static <T> T max(T[] self, @ClosureParams(value=FromString.class, options={"T","T,T"}) Closure closure) { return max((Iterable<T>)toList(self), closure); }
int params = closure.getMaximumNumberOfParameters(); if (params != 1) { return max(self, new ClosureComparator<T>(closure));
/** * Adds max() method to Object arrays. * * @param self an Object array * @return the maximum value * @see #max(java.util.Collection) */ public static Object max(Object[] self) { return max(toList(self)); }
/** * Adds max() method to Object arrays. * * @param self an Object array * @return the maximum value * @see #max(java.util.Collection) * @since 1.5.5 */ public static <T> T max(T[] self) { return max(toList(self)); }
/** * Selects the maximum value found from the Iterator using the given comparator. * * @param self an Iterator * @param comparator a Comparator * @return the maximum value * @since 1.5.5 */ public static <T> T max(Iterator<T> self, Comparator<T> comparator) { return max(toList(self), comparator); }
/** * Selects the maximum value found from the Object array using the given comparator. * * @param self an Object array * @param comparator a Comparator * @return the maximum value * @since 1.5.5 */ public static <T> T max(T[] self, Comparator<T> comparator) { return max(toList(self), comparator); }
/** * Adds max() method to Object arrays. * * @param self an Object array * @return the maximum value * @see #max(java.util.Collection) * @since 1.5.5 */ public static <T> T max(T[] self) { return max(toList(self)); }
/** * Selects the maximum value found from the Iterator using the given comparator. * * @param self an Iterator * @param comparator a Comparator * @return the maximum value * @since 1.5.5 */ public static <T> T max(Iterator<T> self, Comparator<T> comparator) { return max(toList(self), comparator); }
/** * Adds max() method to Iterator objects. The iterator will become * exhausted of elements after determining the maximum value. * * @param self an Iterator * @return the maximum value * @see groovy.util.GroovyCollections#max(java.util.Collection) * @since 1.5.5 */ public static <T> T max(Iterator<T> self) { return max(toList(self)); }
public static<T extends Object >T max(T[] self, Closure closure) { if ((!Caller.isAsynchronous(self, "max", closure))&&(!Caller.isAsynchronous(CpsDefaultGroovyMethods.class, "max", self, closure))) { return DefaultGroovyMethods.max(self, closure); } return CpsDefaultGroovyMethods.$max__java_lang_Object_array__groovy_lang_Closure(self, closure); }
public static<T extends Object >T max(Iterator<T> self, Closure closure) { if ((!Caller.isAsynchronous(self, "max", closure))&&(!Caller.isAsynchronous(CpsDefaultGroovyMethods.class, "max", self, closure))) { return DefaultGroovyMethods.max(self, closure); } return CpsDefaultGroovyMethods.$max__java_util_Iterator__groovy_lang_Closure(self, closure); }