add min and max

This commit is contained in:
Looly 2019-09-11 16:28:34 +08:00
parent c6f2754221
commit a9b08161c3
3 changed files with 28 additions and 1 deletions

View File

@ -19,6 +19,7 @@
* 【setting】 SettingLoader支持自定义分隔符
* 【http】 Content-Type添加默认值issue#I11YHI@Gitee
* 【socket】 增加Closeable接口issue#532@Github
* 【core】 CollUtil增加min和max方法
### Bug修复
* 【core】 修复NetUtil.getUsableLocalPort问题pr#69@Gitee

View File

@ -2499,6 +2499,32 @@ public class CollUtil {
return values;
}
/**
* 取最大值
*
* @param <T> 元素类型
* @param coll 集合
* @return 最大值
* @since 4.6.5
* @see Collections#max(Collection)
*/
public static <T extends Comparable<? super T>> T max(Collection<T> coll) {
return Collections.max(coll);
}
/**
* 取最大值
*
* @param <T> 元素类型
* @param coll 集合
* @return 最大值
* @since 4.6.5
* @see Collections#min(Collection)
*/
public static <T extends Comparable<? super T>> T min(Collection<T> coll) {
return Collections.min(coll);
}
// ---------------------------------------------------------------------------------------------- Interface start
/**

View File

@ -19,7 +19,7 @@ import cn.hutool.core.util.ArrayUtil;
* @param <V>
*/
public class TableMap<K, V> implements Map<K, V>, Serializable {
private static final long serialVersionUID = -5852304468076152385L;
private static final long serialVersionUID = 1L;
private List<K> keys;
private List<V> values;