net.sf.zig_project.gpl.common.arrays
Class LinearArraySizeSelector
java.lang.Object
net.sf.zig_project.gpl.common.arrays.LinearArraySizeSelector
- All Implemented Interfaces:
- ArraySizeSelector
- public class LinearArraySizeSelector
- extends Object
- implements ArraySizeSelector
A LinearArraySizeSelector recommends that an array be resized based on
it's current size, multipled by a constant scalar value.
- Version:
- September 15, 2004
- Author:
- Frank Ziglar
Method Summary |
int |
grow(int n,
int rm)
Recommends that the array grow by the set proportion. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LinearArraySizeSelector
public LinearArraySizeSelector(float f)
- Constructs a Linear Selector based on the provided ratio.
If the ratio is < 1.0, it is considered a growth rate,
and recommendations are increased by that proportion.
Otherwise, the array is scaled by that proportion directly.
- Parameters:
f
- the scalar to base recomendations on
- Throws:
IllegalArgumentException
- if f < 0.0
grow
public int grow(int n,
int rm)
- Recommends that the array grow by the set proportion. However,
if more room is required, it only recommends that the array
size be incremented by the required room.
- Specified by:
grow
in interface ArraySizeSelector
- Parameters:
n
- the length of the currently allocated arrayrm
- an estimate of the number of elements that
need to be added to the array before the size is
reconsidered.
- Returns:
- the total recommended size for a new array