net.sf.zig_project.gpl.common.arrays
Class ExponentialRatioArraySizeSelector
java.lang.Object
net.sf.zig_project.gpl.common.arrays.ExponentialRatioArraySizeSelector
- All Implemented Interfaces:
- ArraySizeSelector
- public final class ExponentialRatioArraySizeSelector
- extends Object
- implements ArraySizeSelector
The Exponential Array Sizer recommends an array size. The result is
based on a growth ratio, scaled by the current array size. The growth
ratio used is an exponential fall off, starting from a high ratio, and
moving towards a low ratio. This results in recommended increases that
are on a large scale for small arrays (such as those just initialized),
and small scales for large arrays (to preserve memory).
- Version:
- September 15, 2004
- Author:
- Frank Ziglar
- See Also:
ArraySizeSelector.DEFAULT
Method Summary |
int |
grow(int n,
int rm)
When an array size is increased, this method will recommend a
new size. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ExponentialRatioArraySizeSelector
public ExponentialRatioArraySizeSelector(double xpnt,
double min,
double range)
grow
public int grow(int n,
int rm)
- Description copied from interface:
ArraySizeSelector
- When an array size is increased, this method will recommend a
new size. Implementations are required to ensure that the
returned value is always
>= current_size+extra_room
.
This value will typically be larger than just the sum however,
in order to minimized the number of times the array need be
reallocated.
- 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