net.larsan.urd.util
Class ArrayUtils

java.lang.Object
  |
  +--net.larsan.urd.util.ArrayUtils

public class ArrayUtils
extends java.lang.Object

Some static array helper methods.

Version:
Alpha-0.1 / 2002-10-06 21:37
Author:
Lars J. Nilsson

Constructor Summary
ArrayUtils()
           
 
Method Summary
static java.util.Iterator getIterator(java.lang.Object[] array)
          Wrap an object array on an iterator.
static double[] grow(double[] original, int increase)
          Grow an double array with a number of elements.
static int[] grow(int[] original, int increase)
          Grow an int array with a number of elements.
static long[] grow(long[] original, int increase)
          Grow an long array with a number of elements.
static java.lang.Object grow(java.lang.Object[] original, int increase)
          Grow an object array with a number of elements.
static double[] shrink(double[] original, int descrease)
          Shrink an array by a number of elements.
static int[] shrink(int[] original, int descrease)
          Shrink an array by a number of elements.
static long[] shrink(long[] original, int descrease)
          Shrink an array by a number of elements.
static java.lang.Object shrink(java.lang.Object[] original, int descrease)
          Shrink an array by a number of elements.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayUtils

public ArrayUtils()
Method Detail

grow

public static java.lang.Object grow(java.lang.Object[] original,
                                    int increase)
Grow an object array with a number of elements. This creates a new array and copies the parameter array across.

Parameters:
original - Original array to grow
increase - Size to increase original array with
Returns:
An object array

grow

public static int[] grow(int[] original,
                         int increase)
Grow an int array with a number of elements. This creates a new array and copies the parameter array across.

Parameters:
original - Original array to grow
increase - Size to increase original array with
Returns:
An int array

grow

public static long[] grow(long[] original,
                          int increase)
Grow an long array with a number of elements. This creates a new array and copies the parameter array across.

Parameters:
original - Original array to grow
increase - Size to increase original array with
Returns:
A long array

grow

public static double[] grow(double[] original,
                            int increase)
Grow an double array with a number of elements. This creates a new array and copies the parameter array across.

Parameters:
original - Original array to grow
increase - Size to increase original array with
Returns:
An double array

shrink

public static java.lang.Object shrink(java.lang.Object[] original,
                                      int descrease)
                               throws java.lang.ArrayIndexOutOfBoundsException
Shrink an array by a number of elements. If the array contains elements in the partion to be removed these will be lost. If the array length minus the decreasement is negative an ArrayIndexOutOfBoundsException will be thrown.

Parameters:
original - Original array to shrink
Returns:
An Object array
Throws:
java.lang.ArrayIndexOutOfBoundsException - If the array length becomes less than zero

shrink

public static int[] shrink(int[] original,
                           int descrease)
                    throws java.lang.ArrayIndexOutOfBoundsException
Shrink an array by a number of elements. If the array contains elements in the partion to be removed these will be lost. If the array length minus the decreasement is negative an ArrayIndexOutOfBoundsException will be thrown.

Parameters:
original - Original array to shrink
Returns:
An int array
Throws:
java.lang.ArrayIndexOutOfBoundsException - If the array length becomes less than zero

shrink

public static long[] shrink(long[] original,
                            int descrease)
                     throws java.lang.ArrayIndexOutOfBoundsException
Shrink an array by a number of elements. If the array contains elements in the partion to be removed these will be lost. If the array length minus the decreasement is negative an ArrayIndexOutOfBoundsException will be thrown.

Parameters:
original - Original array to shrink
Returns:
A long array
Throws:
java.lang.ArrayIndexOutOfBoundsException - If the array length becomes less than zero

shrink

public static double[] shrink(double[] original,
                              int descrease)
                       throws java.lang.ArrayIndexOutOfBoundsException
Shrink an array by a number of elements. If the array contains elements in the partion to be removed these will be lost. If the array length minus the decreasement is negative an ArrayIndexOutOfBoundsException will be thrown.

Parameters:
original - Original array to shrink
Returns:
An double array
Throws:
java.lang.ArrayIndexOutOfBoundsException - If the array length becomes less than zero

getIterator

public static java.util.Iterator getIterator(java.lang.Object[] array)
Wrap an object array on an iterator. This iterator does not support removal.

Parameters:
array - Array to wrap
Returns:
An iterator over the array