BRUtil - Making Java a Kinder, Gentler, Place to be.

brutil
Class Array

java.lang.Object
  |
  +--brutil.Array
All Implemented Interfaces:
Collection

public class Array
extends java.lang.Object
implements Collection

This is an automatically-resizing array list. It starts as a single array of objects (initialized to 'initialSize' field, and upon necessity grows and adds Subarrays of size 'capacityIncrement' to simulate a seamless array list.


Inner Class Summary
protected  class Array.Subarray
          Subarrays act as sub-modules for the Array.
 
Field Summary
protected static int defaultCapacityIncrement
           
protected static int defaultInitialCapacity
           
protected static int STARTSIZE
           
 
Constructor Summary
Array()
          Default Constructor, initial capacity = 10, increment = 10
Array(int initialCapacity)
          Instantiates array with specified initial capacity.
Array(int initialCapacity, int capacityIncrement)
          Instantiates array with specified initial capacity and capacityIncrement, uses the default value for the maximum number of SubArrays
Array(int initialCapacity, int capacityIncrement, int maxSize)
          The main constructor.
 
Method Summary
 void clear()
          Sets every element in the Array to null
protected  Array.Subarray createSubarray(int size)
           
protected  Array.Subarray[] createSubarrayArray(int size)
           
 java.lang.Object get(int index)
          Gets the object at the specified index.
protected  void initMemory()
           
 boolean isEmpty()
          Returns true if empty
protected  int maxLength()
          Returns the maximum length of the Array.
 brutil.behavior.FrequencyDist predictTime(java.lang.String method, brutil.behavior.State currentState)
           
 java.lang.Object set(java.lang.Object obj, int index)
          Overwrites the element at this index to be the specified object and returns the former object.
 int size()
          Returns the size of the array from List interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultInitialCapacity

protected static final int defaultInitialCapacity

defaultCapacityIncrement

protected static final int defaultCapacityIncrement

STARTSIZE

protected static final int STARTSIZE
Constructor Detail

Array

public Array()
Default Constructor, initial capacity = 10, increment = 10

Array

public Array(int initialCapacity)
Instantiates array with specified initial capacity.

Array

public Array(int initialCapacity,
             int capacityIncrement)
Instantiates array with specified initial capacity and capacityIncrement, uses the default value for the maximum number of SubArrays

Array

public Array(int initialCapacity,
             int capacityIncrement,
             int maxSize)
The main constructor. No parameter may be zero; zero-sized arrays are pointless.
Method Detail

predictTime

public brutil.behavior.FrequencyDist predictTime(java.lang.String method,
                                                 brutil.behavior.State currentState)

set

public java.lang.Object set(java.lang.Object obj,
                            int index)
Overwrites the element at this index to be the specified object and returns the former object.

get

public java.lang.Object get(int index)
Gets the object at the specified index.

size

public int size()
Returns the size of the array from List interface.
Specified by:
size in interface Collection

isEmpty

public boolean isEmpty()
Returns true if empty
Specified by:
isEmpty in interface Collection

maxLength

protected int maxLength()
Returns the maximum length of the Array.

clear

public void clear()
Sets every element in the Array to null
Specified by:
clear in interface Collection

initMemory

protected void initMemory()

createSubarray

protected Array.Subarray createSubarray(int size)

createSubarrayArray

protected Array.Subarray[] createSubarrayArray(int size)


BRUtil - Making Java a Kinder, Gentler, Place to be.