Package cn.sliew.milky.common.util
Class ArrayUtil
- java.lang.Object
-
- cn.sliew.milky.common.util.ArrayUtil
-
public class ArrayUtil extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static intMAX_ARRAY_LENGTHMaximum length for an array (Integer.MAX_VALUE - RamUsageEstimator.NUM_BYTES_ARRAY_HEADER).
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intoversize(int minTargetSize, int bytesPerElement)Returns an array size >= minTargetSize, generally over-allocating exponentially to achieve amortized linear-time cost as the array grows.
-
-
-
Method Detail
-
oversize
public static int oversize(int minTargetSize, int bytesPerElement)Returns an array size >= minTargetSize, generally over-allocating exponentially to achieve amortized linear-time cost as the array grows.NOTE: this was originally borrowed from Python 2.4.2 listobject.c sources (attribution in LICENSE.txt), but has now been substantially changed based on discussions from java-dev thread with subject "Dynamic array reallocation algorithms", started on Jan 12 2010.
- Parameters:
minTargetSize- Minimum required value to be returned.bytesPerElement- Bytes used by each element of the array. See constants inRamUsageEstimator.
-
-