Class ArrayUtil
- java.lang.Object
-
- net.automatalib.common.smartcollection.ArrayUtil
-
public final class ArrayUtil extends Object
Utility methods for arrays.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
computeNewCapacity(int length, int requiredCapacity)
A convenient method for callingcomputeNewCapacity(length, requiredCapacity, 0)
.static int
computeNewCapacity(int length, int requiredCapacity, int nextCapacityHint)
Computes the size of an array that is required to holdrequiredCapacity
number of elements.
-
-
-
Method Detail
-
computeNewCapacity
public static int computeNewCapacity(int length, int requiredCapacity)
A convenient method for callingcomputeNewCapacity(length, requiredCapacity, 0)
.- Parameters:
length
- the current length of the arrayrequiredCapacity
- the immediately required capacity- Returns:
- the size of an array that is guaranteed to hold
requiredCapacity
number of elements. - See Also:
computeNewCapacity(int, int, int)
-
computeNewCapacity
public static int computeNewCapacity(int length, int requiredCapacity, int nextCapacityHint)
Computes the size of an array that is required to holdrequiredCapacity
number of elements.This method first tries to increase the size of the array by a factor of 1.5 to prevent a sequence of successive increases by 1. It then evaluates the
nextCapacityHint
parameter as well as therequiredCapacity
parameter to determine the next size.- Parameters:
length
- the current length of the arrayrequiredCapacity
- the immediately required capacitynextCapacityHint
- a hint for future capacity requirements that may not be required as of now- Returns:
- the size of an array that is guaranteed to hold
requiredCapacity
number of elements.
-
-