uka.util
Class EnlargingArray

java.lang.Object
  extended byuka.util.EnlargingArray
All Implemented Interfaces:
java.io.Serializable

public final class EnlargingArray
extends java.lang.Object
implements java.io.Serializable

A simple wrapper class for a regular Java array. In addition to the features of built-in Java arrays, instances of this class can be enlarged either automatically by setting a value to a position that exceeds the current size() of this array, or manually be explicitely setting the size.

This class is more convenient than a ArrayList, if direct manipulation of the array size is required. In addition there are customized versions of this class for all Java basic types.

Author:
Bernhard Haumacher
See Also:
Serialized Form

Field Summary
(package private)  java.lang.Object[] array
           
 java.lang.Object DEFAULT
           
(package private)  int length
           
static int MIN_SIZE
           
 
Constructor Summary
EnlargingArray()
           
EnlargingArray(EnlargingArray other)
           
EnlargingArray(int length)
           
EnlargingArray(int length, java.lang.Object DEFAULT)
           
 
Method Summary
 java.lang.Object add(java.lang.Object obj)
           
 void appendTo(ToString s)
           
 void clear()
           
static void copy(EnlargingArray src, int srcIndex, EnlargingArray dst, int dstIndex, int length)
           
private  void enlarge(int newLength)
           
 void fill(int start, int stop, java.lang.Object value)
           
 java.lang.Object get(int idx)
           
 Iterator iterator()
           
 void move(int moveSrc, int moveDst, int moveLength)
           
 void permute(Permutation permutation)
          Permutes the contents of this array.
 java.lang.Object pop()
          Returns the element at position size() - 1 and shrinks the size of this array by 1.
 java.lang.Object remove(int idx)
           
 java.lang.Object set(int idx, java.lang.Object obj)
           
 void setSize(int size)
           
 int size()
           
 java.lang.Object test(int idx)
          Same as get(int), except for indices larger than or equal to the array length.
 java.lang.Object[] toArray(java.lang.Object[] a)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT

public final java.lang.Object DEFAULT

length

int length

array

java.lang.Object[] array

MIN_SIZE

public static final int MIN_SIZE
See Also:
Constant Field Values
Constructor Detail

EnlargingArray

public EnlargingArray()

EnlargingArray

public EnlargingArray(int length)

EnlargingArray

public EnlargingArray(int length,
                      java.lang.Object DEFAULT)

EnlargingArray

public EnlargingArray(EnlargingArray other)
Method Detail

get

public java.lang.Object get(int idx)

test

public java.lang.Object test(int idx)
Same as get(int), except for indices larger than or equal to the array length. For these cases, test(int) returns a null value instead of throwing an exception.


set

public java.lang.Object set(int idx,
                            java.lang.Object obj)

copy

public static void copy(EnlargingArray src,
                        int srcIndex,
                        EnlargingArray dst,
                        int dstIndex,
                        int length)

add

public java.lang.Object add(java.lang.Object obj)

remove

public java.lang.Object remove(int idx)

pop

public java.lang.Object pop()
Returns the element at position size() - 1 and shrinks the size of this array by 1. This method enables a stack-like usage of this array.


permute

public void permute(Permutation permutation)
Permutes the contents of this array. The element at index n is moved to index permutation.compute(n).


setSize

public void setSize(int size)

size

public int size()

clear

public void clear()

move

public void move(int moveSrc,
                 int moveDst,
                 int moveLength)

fill

public void fill(int start,
                 int stop,
                 java.lang.Object value)

enlarge

private final void enlarge(int newLength)

iterator

public Iterator iterator()

toArray

public java.lang.Object[] toArray(java.lang.Object[] a)

toString

public java.lang.String toString()

appendTo

public void appendTo(ToString s)