net.sf.zig_project.gpl.common.arrays
Class DirectArraySizeSelector

java.lang.Object
  extended bynet.sf.zig_project.gpl.common.arrays.DirectArraySizeSelector
All Implemented Interfaces:
ArraySizeSelector

public class DirectArraySizeSelector
extends Object
implements ArraySizeSelector

The Direct Array Size Selector always recommends array growth by a single, fixed, size. Eg. if you construct one with a size param of 100, it will recommend that the array should grow by at a capacity of 100 each time a reallocation is required.

Version:
September 15, 2004
Author:
Frank Ziglar

Field Summary
 
Fields inherited from interface net.sf.zig_project.gpl.common.arrays.ArraySizeSelector
DEFAULT
 
Constructor Summary
DirectArraySizeSelector(int sz)
          Construct a Direct Selector
 
Method Summary
 int grow(int n, int rm)
          Recommends the array grow by the fixed growth size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DirectArraySizeSelector

public DirectArraySizeSelector(int sz)
Construct a Direct Selector

Parameters:
sz - the fixed growth size to recommend
Throws:
IllegalArgumentException - if sz < 0
Method Detail

grow

public int grow(int n,
                int rm)
Recommends the array grow by the fixed growth size. However, if the amount of subsequent room required is greater it is used instead.

Specified by:
grow in interface ArraySizeSelector
Parameters:
n - the length of the currently allocated array
rm - 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