|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jscience.architecture.traffic.util.ArrayUtils
public class ArrayUtils
These functions can be used to add and remove elements from an array.
| Constructor Summary | |
|---|---|
ArrayUtils()
|
|
| Method Summary | |
|---|---|
static java.lang.Object |
addArray(java.lang.Object ar1,
java.lang.Object ar2)
Creates a new array containing the elements of two arrays. |
static java.lang.Object |
addArrayUnique(java.lang.Object ar1,
java.lang.Object ar2)
Creates a new array containing the unique elements of two arrays. |
static java.lang.Object |
addElement(java.lang.Object ar,
java.lang.Object elem)
Adds an element to the end of an array. |
static java.lang.Object |
addElementUnique(java.lang.Object ar,
java.lang.Object elem)
Adds an element to the end of an array, if and only if the element is not already in the array. |
static java.lang.Object |
adjustArraySize(java.lang.Object[] input,
int newLength,
java.lang.Class newClass)
Change the size of an array. |
static java.lang.Object |
concatArray(java.lang.Object ar)
Concatenates a two dimensional array to a one dimensional |
static java.lang.Object |
createArray(java.lang.String arrayName,
int length)
Yet another way to create an array |
static java.lang.Object |
createArray(java.lang.String className,
int length,
int dimension)
Creates a n-dimensional array of a certain class |
static java.lang.Object |
createSingleArray(java.lang.String className,
int length)
Creates a one-dimensional array of a certain class. |
static java.lang.Object |
cropArray(java.lang.Object ar,
int length)
Crops an array to specified length. |
static int |
findElement(java.lang.Object ar,
java.lang.Object elem)
Checks if an element is part of an array, using the == operator. |
static int |
findElementA(java.lang.Object[] ar,
java.lang.Object elem)
DOCUMENT ME! |
static java.lang.String |
getAtomaryComponent(java.lang.String className)
Calculates the atomary component of an array by the name of its class. |
static java.lang.String |
getComponentClassName(java.lang.String className)
Calculates the direct component of an array by the name of its class. |
static int |
getDimensionClassName(java.lang.String className)
Determines the dimension of an array by the name of its class |
static java.util.Enumeration |
getEmptyEnumeration()
Returns an empty Enumeration |
static java.util.Enumeration |
getEnumeration(java.lang.Object[] ar)
Returns an Enumeration over the given array |
static java.util.Enumeration |
getEnumeration(java.lang.Object[][] ar)
Returns an Enumeration over the given 2d array |
static java.lang.Object[] |
randomizeArray(java.lang.Object[] ar)
Replaces the elements of the provided array in a random fashion. |
static int[] |
randomizeIntArray(int[] arr,
java.util.Random r)
|
static java.lang.Object |
remElement(java.lang.Object ar,
int pos)
Removes the element at given position, and moves all elements above that 1 position down. |
static java.lang.Object |
remElement(java.lang.Object ar,
java.lang.Object elem)
Removes an element from an array. |
static java.lang.Object |
resizeArray(java.lang.Object[] ar,
int length)
Resizes an array to specified length. |
static java.lang.Object |
setElement(java.lang.Object ar,
java.lang.Object oldo,
java.lang.Object newo)
Replaces an element in an array with another. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ArrayUtils()
| Method Detail |
|---|
public static java.lang.Object addElement(java.lang.Object ar,
java.lang.Object elem)
ar - The array to add an element to.elem - The element to add to the end of the array.
public static java.lang.Object addElementUnique(java.lang.Object ar,
java.lang.Object elem)
ar - The array to add an element to.elem - The element to add to the end of the array.
public static java.lang.Object addArray(java.lang.Object ar1,
java.lang.Object ar2)
ar1 - The array to add the other array to.ar2 - The array to add at the end of the first array.
public static java.lang.Object addArrayUnique(java.lang.Object ar1,
java.lang.Object ar2)
ar1 - The array to add the other array to.ar2 - The array to add at the end of the first array.
public static java.lang.Object remElement(java.lang.Object ar,
int pos)
ar - The array to remove the element from.pos - The position of the element to remove.
public static java.lang.Object remElement(java.lang.Object ar,
java.lang.Object elem)
ar - The array to remove the element from.elem - The element to remove.
public static java.lang.Object setElement(java.lang.Object ar,
java.lang.Object oldo,
java.lang.Object newo)
ar - The array to replace the element in.oldo - The element to replace.newo - The element to replace it with.
public static int findElement(java.lang.Object ar,
java.lang.Object elem)
ar - The array to search.elem - The element to search for.
public static int findElementA(java.lang.Object[] ar,
java.lang.Object elem)
ar - DOCUMENT ME!elem - DOCUMENT ME!
public static int[] randomizeIntArray(int[] arr,
java.util.Random r)
public static java.lang.Object[] randomizeArray(java.lang.Object[] ar)
ar - The array to randomize.
public static java.lang.Object adjustArraySize(java.lang.Object[] input,
int newLength,
java.lang.Class newClass)
throws java.lang.ClassNotFoundException,
java.lang.InstantiationException,
java.lang.IllegalAccessException
input - The original arraynewLength - The new length of the arraynewClass - The class of the new elements. It is necessary that
objects of this class can be instantiated with
Class.newInstance. If the new length is less than the old length
of the array, then this parameter is irrelevant.
java.lang.ClassNotFoundException - If this method wants to create objects,
but it cannot find the class that newClass is referring to.
java.lang.InstantiationException - If this method wants to create objects,
but something goes wrong.
java.lang.IllegalAccessException - DOCUMENT ME!
public static java.lang.Object cropArray(java.lang.Object ar,
int length)
ar - The array to crop.length - The length to crop to.
public static java.lang.Object resizeArray(java.lang.Object[] ar,
int length)
ar - The array to resize.length - The length to resize to.
public static java.lang.Object concatArray(java.lang.Object ar)
ar - Two dimensional array to concatenate
public static int getDimensionClassName(java.lang.String className)
className - classname of an array.
public static java.lang.String getComponentClassName(java.lang.String className)
className - classname of an array
public static java.lang.String getAtomaryComponent(java.lang.String className)
className - classname of an array
public static java.lang.Object createSingleArray(java.lang.String className,
int length)
throws java.lang.ClassNotFoundException
className - The classname of the components of this array. This
method accepts normal class names and the one letter
designations for primitive types as used in java.lang.Class.length - The length of the array. Positive int of course.
java.lang.ClassNotFoundException - It's all in the name
public static java.lang.Object createArray(java.lang.String className,
int length,
int dimension)
throws java.lang.ClassNotFoundException
className - The classname of the components of this array. This
method accepts normal class names and the one letter
designations for primitive types as used in java.lang.Class.length - The length of the array. Positive int of course.dimension - The dimension of this array
java.lang.ClassNotFoundException - It's all in the name
public static java.lang.Object createArray(java.lang.String arrayName,
int length)
throws java.lang.ClassNotFoundException
arrayName - The classname of the array that you want to createlength - The desired length
java.lang.ClassNotFoundException - It's all in the namepublic static java.util.Enumeration getEnumeration(java.lang.Object[] ar)
ar - DOCUMENT ME!
public static java.util.Enumeration getEnumeration(java.lang.Object[][] ar)
ar - DOCUMENT ME!
public static java.util.Enumeration getEmptyEnumeration()
java.util.NoSuchElementException - DOCUMENT ME!
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||