nextapp.echo.util
Class DynamicIntegerArray

java.lang.Object
  extended by nextapp.echo.util.DynamicIntegerArray
All Implemented Interfaces:
java.io.Serializable

public class DynamicIntegerArray
extends java.lang.Object
implements java.io.Serializable

A limited implementation of a variable-length array of integers.

Because the get() method of this object returns a primitive integer type, the user must specify a value that should be returned in the even no value is contained at the specified index when it is called. This value is permanently set at instantiation.

This class is VERY inefficient when used to store only a few values at high indices. This object will allocate an array with containers at values from 0 to the highest set index.

This class is a supporting class for the Echo framework. It is not intended for use by applications.

See Also:
Serialized Form

Constructor Summary
DynamicIntegerArray()
          Creates a new DynamicIntegerArray with a "null value" of 0.
DynamicIntegerArray(int nullValue)
          Creates a new DynamicIntegerArray with the specified "null value".
 
Method Summary
 boolean contains(int index)
          Returns true if the array contains a value at the specified index.
 int get(int index)
          Returns the value in the array at the specified index.
 void set(int index, int value)
          Sets the value at the specified index to the given value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DynamicIntegerArray

public DynamicIntegerArray()
Creates a new DynamicIntegerArray with a "null value" of 0.


DynamicIntegerArray

public DynamicIntegerArray(int nullValue)
Creates a new DynamicIntegerArray with the specified "null value".

Parameters:
nullValue - The value that is used to indicate null values.
Method Detail

contains

public boolean contains(int index)
Returns true if the array contains a value at the specified index.

Parameters:
index - The array index to analyze.
Returns:
True if the array contains a value at the specified index.

get

public int get(int index)
Returns the value in the array at the specified index.

Parameters:
index - The index of the value to be returned.
Returns:
The value in the array at the specified index. If no value exists at the specified index, -1 is returned.

set

public void set(int index,
                int value)
Sets the value at the specified index to the given value.

Parameters:
index - The index in the array to be modified.
value - The new value to be placed at the specified index.