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

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

public final class StuntedArraySizeSelector
extends Object
implements ArraySizeSelector

A StuntedArraySizeSelector prohibits the growth of an array beyond it's origional size. Calls to the grow method of this class will never return, always throwing an exception instead.

Version:
September 15, 2004
Author:
Frank Ziglar

Field Summary
static StuntedArraySizeSelector DEFAULT_INSTANCE
          The instance of StuntedArraySizeSelector to use.
 
Fields inherited from interface net.sf.zig_project.gpl.common.arrays.ArraySizeSelector
DEFAULT
 
Method Summary
 int grow(int current_size, int room)
          This method prevents an array from growing by always throwing an exception, instead of returning a recommended size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_INSTANCE

public static final StuntedArraySizeSelector DEFAULT_INSTANCE
The instance of StuntedArraySizeSelector to use. There is no benefit in creating multiple instances of this class.

Method Detail

grow

public int grow(int current_size,
                int room)
This method prevents an array from growing by always throwing an exception, instead of returning a recommended size.

Specified by:
grow in interface ArraySizeSelector
Parameters:
current_size - the length of the currently allocated array
room - 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
Throws:
IllegalStateException