diff --git a/protocol/src/main/java/com/zfoo/protocol/collection/CollectionUtils.java b/protocol/src/main/java/com/zfoo/protocol/collection/CollectionUtils.java index a51818d01..91cd63e81 100644 --- a/protocol/src/main/java/com/zfoo/protocol/collection/CollectionUtils.java +++ b/protocol/src/main/java/com/zfoo/protocol/collection/CollectionUtils.java @@ -115,6 +115,14 @@ public static int comfortableCapacity(int capacity) { : (capacity < 32 ? 64 : Math.min(capacity << 1, IOUtils.BYTES_PER_MB)); } + public static int capacity(int expectedSize) { + if (expectedSize < 3) { + return expectedSize + 1; + } + return (int) ((float) expectedSize / 0.75F + 1.0F); + } + + // ----------------------------------归并排序---------------------------------- /**