mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
优化IndexedComparator性能
This commit is contained in:
@@ -55,7 +55,7 @@ public class IndexedComparator<T> implements Comparator<T> {
|
||||
public IndexedComparator(boolean atEndIfMiss, T... objs) {
|
||||
Assert.notNull(objs, "'objs' array must not be null");
|
||||
this.atEndIfMiss = atEndIfMiss;
|
||||
map = new HashMap<>(1 + (int) (objs.length / 0.75));
|
||||
map = new HashMap<>(objs.length, 1);
|
||||
for (int i = 0; i < objs.length; i++) {
|
||||
map.put(objs[i], i);
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@ import java.util.Comparator;
|
||||
*
|
||||
* @param <T> 被排序元素类型
|
||||
* @author looly
|
||||
* @since 4.1.5
|
||||
* @since 5.8.30
|
||||
*/
|
||||
public class ArrayIndexedComparator<T> implements Comparator<T> {
|
||||
|
||||
|
Reference in New Issue
Block a user