org.ourgrid.common.util
Class ArrayUtil

java.lang.Object
  extended by org.ourgrid.common.util.ArrayUtil

public class ArrayUtil
extends java.lang.Object

This is a auxiliar class that incloses many util functionalities related to the Array data structure.


Constructor Summary
ArrayUtil()
           
 
Method Summary
static void concat(java.lang.Object[] array1, java.lang.Object[] array2, java.lang.Object[] mergedArray)
          Puts all the elements from two source arrays at another destiny one.
static int find(java.lang.Object element, java.lang.Object[] array1)
          Search for a object element into a array.
static void invert(java.lang.Object[] objArray)
          This method inverts the order of the elements in objArray.
static void removeFirst(java.lang.Object[] objArray, java.lang.Object[] resultArray)
          This method removes the fisrt element of an array, if the array contains only one element, it returns null.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayUtil

public ArrayUtil()
Method Detail

removeFirst

public static void removeFirst(java.lang.Object[] objArray,
                               java.lang.Object[] resultArray)
This method removes the fisrt element of an array, if the array contains only one element, it returns null.

Parameters:
objArray - The source array. Their first element will be removed.
resultArray - Is the source array without the first element, or null if there is no more elements in the array.

invert

public static void invert(java.lang.Object[] objArray)
This method inverts the order of the elements in objArray.

Parameters:
objArray - the array that will have its elements inverted.

concat

public static void concat(java.lang.Object[] array1,
                          java.lang.Object[] array2,
                          java.lang.Object[] mergedArray)
Puts all the elements from two source arrays at another destiny one. It will put first in sequence all the elements from the first array then the sequence of the other one. It will only happens if the destiny array has more or equals then the first source array Length plus the length from the second one.

Parameters:
array1 - the first array source.
array2 - the second array source.
mergedArray - the destiny array.

find

public static int find(java.lang.Object element,
                       java.lang.Object[] array1)
Search for a object element into a array. It will search for the element using the equals method of it.

Parameters:
element - the element to search
array1 - the array where to search.
Returns:
the index of the element if it was found and -1 otherwise.