org.databene.commons
Class ArrayUtil

java.lang.Object
  extended by org.databene.commons.ArrayUtil

public final class ArrayUtil
extends java.lang.Object

Provides array-related operations.

Created: 09.06.2006 21:31:49

Since:
0.1
Author:
Volker Bergmann

Constructor Summary
ArrayUtil()
           
 
Method Summary
static
<T> T[]
append(T[] array, T value)
           
static java.lang.Class arrayType(java.lang.Class componentType)
           
static
<T> T[]
buildArrayOfType(java.lang.Class<T> componentType, T... values)
           
static
<T> T[]
commonElements(java.lang.Class<T> componentType, T[]... sources)
           
static
<T> T[]
commonElements(T[]... sources)
           
static
<T> java.lang.Class<T>
componentType(T[] array)
           
static
<T> boolean
contains(T[] array, T element)
          Tells if an array contains a specific element
static
<T> T[]
copyOfRange(java.lang.Object[] array, int offset, int length, java.lang.Class<T> componentType)
           
static
<T> T[]
copyOfRange(T[] array, int offset, int length)
           
static
<T> boolean
endsWithSequence(T[] candidates, T[] searched)
          Tells if an array ends with a specified sub array
static
<T> boolean
equalsIgnoreOrder(T[] a1, T[] a2)
          Tells if two arrays have the same content, independent of the ordering
static
<T> int
indexOf(T searchedItem, T[] array)
          Tells the first index under which an item is found in an array.
static boolean isEmpty(java.lang.Object[] values)
           
static
<T> java.util.Iterator<T>
iterator(T[] array)
           
static
<T> T
lastElement(T[] array)
           
static
<T> T[]
newInstance(java.lang.Class<T> componentType, int length)
           
static
<T> T[]
remove(T[] array, int indexToRemove)
           
static char[] revert(char[] array)
           
static
<T> T[]
revert(T[] array)
           
static
<T> T[]
toArray(T... values)
           
static char[] toCharArray(char... values)
           
static int[] toIntArray(int... values)
           
 
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

copyOfRange

public static <T> T[] copyOfRange(T[] array,
                                  int offset,
                                  int length)

componentType

public static <T> java.lang.Class<T> componentType(T[] array)

copyOfRange

public static <T> T[] copyOfRange(java.lang.Object[] array,
                                  int offset,
                                  int length,
                                  java.lang.Class<T> componentType)

remove

public static <T> T[] remove(T[] array,
                             int indexToRemove)

contains

public static <T> boolean contains(T[] array,
                                   T element)
Tells if an array contains a specific element

Parameters:
element - the element to search
array - the array to scan
Returns:
true if the element was found, else false

endsWithSequence

public static <T> boolean endsWithSequence(T[] candidates,
                                           T[] searched)
Tells if an array ends with a specified sub array

Parameters:
candidates - the array to scan
searched - the sub array that is searched
Returns:
true if the array ands with or equals the searched sub array

commonElements

public static <T> T[] commonElements(T[]... sources)

commonElements

public static <T> T[] commonElements(java.lang.Class<T> componentType,
                                     T[]... sources)

equalsIgnoreOrder

public static <T> boolean equalsIgnoreOrder(T[] a1,
                                            T[] a2)
Tells if two arrays have the same content, independent of the ordering

Parameters:
a1 - the first array to compare
a2 - the first array to compare
Returns:
true if the array have the same content, independant of the ordering

indexOf

public static <T> int indexOf(T searchedItem,
                              T[] array)
Tells the first index under which an item is found in an array.

Parameters:
searchedItem -
array -
Returns:
the index of the searched item

toArray

public static <T> T[] toArray(T... values)

toIntArray

public static int[] toIntArray(int... values)

toCharArray

public static char[] toCharArray(char... values)

buildArrayOfType

public static <T> T[] buildArrayOfType(java.lang.Class<T> componentType,
                                       T... values)

iterator

public static <T> java.util.Iterator<T> iterator(T[] array)

revert

public static <T> T[] revert(T[] array)

revert

public static char[] revert(char[] array)

arrayType

public static java.lang.Class arrayType(java.lang.Class componentType)

newInstance

public static <T> T[] newInstance(java.lang.Class<T> componentType,
                                  int length)

append

public static <T> T[] append(T[] array,
                             T value)

isEmpty

public static boolean isEmpty(java.lang.Object[] values)

lastElement

public static <T> T lastElement(T[] array)


Copyright © 2010. All Rights Reserved.