优化IndexedComparator性能

This commit is contained in:
Looly
2024-07-30 11:20:47 +08:00
parent f7fa704d6c
commit 47c2eda038
3 changed files with 3 additions and 2 deletions

View File

@@ -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);
}

View File

@@ -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> {