DESY ACOP Beans Home

com.cosylab.util
Class ArrayHelper

java.lang.Object
  extended by com.cosylab.util.ArrayHelper

public final class ArrayHelper
extends java.lang.Object

A class containing convenience methods for working with arrays.

Version:
$id$
Author:
Miha Kadunc

Constructor Summary
ArrayHelper()
           
 
Method Summary
static boolean contains(java.lang.Object[] array, java.lang.Object key)
           
static int firstGreaterThan(double[] array, double key)
          Works on non sorted arrays
static int firstGreaterThan(double[] array, double key, int rangeStart, int rangeEnd)
          Works on non sorted arrays
static int firstGreaterThanInSorted(double[] array, double key)
          Works fast on sorted arrays
static int firstGreaterThanInSorted(double[] array, double key, int startIndex, int endIndex)
          Works fast on sorted arrays
static int firstIndexOf(java.lang.Object array, java.lang.Object key)
           
static void flip(java.lang.Object array)
           
static java.lang.Object[] getArrayFromEnumeration(java.util.Enumeration e)
           
static java.lang.Object[] getArrayFromIterator(java.util.Iterator i)
           
static
<T> T[]
subArray(java.lang.Class<T> clazz, java.util.List<T> list, int offset, int length)
          Get a sub array of a list.
static double[] toDoubleArray(java.lang.Object array)
           
static int[] toIntArray(java.lang.Number[] input)
           
static java.lang.Integer[] toIntegerArray(int[] input)
           
static java.lang.Object trim(java.lang.Object[] array)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayHelper

public ArrayHelper()
Method Detail

firstGreaterThan

public static int firstGreaterThan(double[] array,
                                   double key)
Works on non sorted arrays


firstGreaterThan

public static int firstGreaterThan(double[] array,
                                   double key,
                                   int rangeStart,
                                   int rangeEnd)
Works on non sorted arrays


firstGreaterThanInSorted

public static int firstGreaterThanInSorted(double[] array,
                                           double key)
Works fast on sorted arrays


firstGreaterThanInSorted

public static int firstGreaterThanInSorted(double[] array,
                                           double key,
                                           int startIndex,
                                           int endIndex)
Works fast on sorted arrays


firstIndexOf

public static int firstIndexOf(java.lang.Object array,
                               java.lang.Object key)

contains

public static boolean contains(java.lang.Object[] array,
                               java.lang.Object key)

getArrayFromEnumeration

public static java.lang.Object[] getArrayFromEnumeration(java.util.Enumeration e)

getArrayFromIterator

public static java.lang.Object[] getArrayFromIterator(java.util.Iterator i)

flip

public static void flip(java.lang.Object array)

toDoubleArray

public static double[] toDoubleArray(java.lang.Object array)

trim

public static java.lang.Object trim(java.lang.Object[] array)

toIntegerArray

public static java.lang.Integer[] toIntegerArray(int[] input)

toIntArray

public static int[] toIntArray(java.lang.Number[] input)

subArray

public static <T> T[] subArray(java.lang.Class<T> clazz,
                               java.util.List<T> list,
                               int offset,
                               int length)
Get a sub array of a list.

Type Parameters:
T - Type of list's elements.
Parameters:
clazz - The type of list's elements.
list - The list.
offset - Offset in the list that will be the first element of the resulting array.
length - Number of elements in the list.
Returns:
Subarray of the list.


Copyright © 2010. All Rights Reserved.