java.lang.Object
com.dynatrace.hash4j.internal.ArraySizeUtil
Utility class for resizing arrays.
-
Method Summary
Modifier and TypeMethodDescriptionstatic intincreaseArraySize(int currentSize, int requiredIndex) Returns a new array size that is greater than the current array size and that supports the given required index.
-
Method Details
-
increaseArraySize
public static int increaseArraySize(int currentSize, int requiredIndex) Returns a new array size that is greater than the current array size and that supports the given required index.If possible, this function doubles the current array size.
It is guaranteed that the return value is greater than the current size. If the current size is equal to
Integer.MAX_VALUE, anOutOfMemoryErrorexception is thrown.This function takes care that the maximum allowed arrow size is not exceeded.
- Parameters:
currentSize- current array sizerequiredIndex- the index that needs to be supported/covered with the new array size- Returns:
- the new array size
- Throws:
OutOfMemoryError- if the current size is equal toInteger.MAX_VALUE
-