List of utility methods to do Collection Max
Collection | max(Collection Return a Collection of all highest-valued T . if (col == null || col.isEmpty()) return null; Collection<T> result = sizedArrayList(col.size()); Iterator<T> it = col.iterator(); T max = it.next(); result.add(max); while (it.hasNext()) { T next = it.next(); ... |
T | max(Collection max T max = null; for (T t : elems) { if (max == null || max.compareTo(t) < 0) { max = t; return max; |
T | max(Collection max T max = null; Iterator<T> it = values.iterator(); if (it.hasNext()) { max = it.next(); while (it.hasNext()) { T n = it.next(); if (n.compareTo(max) > 0) { max = n; ... |
T | max(Collection Returns the maximum of the given values. T max = null; for (T value : values) { if (max == null) { max = value; continue; @SuppressWarnings("unchecked") Comparable<T> comparable = (Comparable<T>) value; ... |
Integer | max(final Collection Returns the max value in the collection. Integer max = null; for (Integer value : values) { if (value == null) { continue; if (max == null || value > max) { max = value; return max; |
T | max(final Collection max if (collection == null || collection.size() <= 0) { return null; T max = null; for (final T elem : collection) { if (max == null || elem.compareTo(max) > 0) { max = elem; return max; |
int | maxLength(Collection Returns the max String length from a Collection . if (strings == null) throw new NullPointerException("strings cannot be null"); Iterator<String> i = strings.iterator(); int max = 0; while (i.hasNext()) { String str = i.next(); if (str != null) { int l = str.length(); ... |
T | maxOr(Collection Like Collections#max(java.util.Collection) except with a default value returned in the case of an empty collection. if (values.isEmpty()) { return defaultVal; } else { return Collections.max(values); |
T | minOrMax(int sign, Collection min Or Max if (values.isEmpty()) { return null; T result = values.iterator().next(); for (T value : values) { if (value == null) { continue; if ((result == null) || (result.compareTo(value) * sign < 0)) { result = value; return result; |
List
| partitionFixed(int maxNumChunks, Collection Fills up chunks out of a collection (given a maximum amount of chunks) i.e. List<List<T>> ret = new ArrayList<>(); if (maxNumChunks == 0 || coll == null) { return ret; Map<Integer, Integer> parts = integerDivided(coll.size(), maxNumChunks); List<Integer> sortedKeys = new ArrayList<Integer>(parts.keySet()); Collections.sort(sortedKeys, Collections.reverseOrder()); Iterator<T> it = coll.iterator(); ... |