|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.intel.gpe.util.arrays.ArrayUtil
public class ArrayUtil
Constais some useful library functions related to arrays
| Constructor Summary | |
|---|---|
ArrayUtil()
|
|
| Method Summary | |
|---|---|
static java.lang.Object |
castElement2Class(java.lang.Class elClazz,
java.lang.Object[] array)
Cast every element of array to class elClazz |
static byte[][] |
divide(byte[] arr,
int chunkSize)
Divides one big array to a number of smaller arrays, each one with length of chunkSize. |
static boolean |
equals(byte[][] a1,
byte[][] a2)
Compares two matrices for equality. |
static byte[] |
merge(byte[]... arrs)
Merges a number of arrays into one big array consequently. |
static int[] |
searchIndices(java.lang.Object[] arr,
java.lang.Object[] toFind)
if exists t that arr[t] equals toFind[i] then result[i]=t, otherwise result[i]=-1 t is the smallest one if two such indexes exists. |
static byte[] |
subarray(byte[] arr,
int beginIdx,
int endIdx)
The same as substring. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ArrayUtil()
| Method Detail |
|---|
public static int[] searchIndices(java.lang.Object[] arr,
java.lang.Object[] toFind)
Object.equals(Object) is used as a comparator. An asymptotic complexity is
arr.length*toFind.length
arr - -
array where search is happeningtoFind - -
elements which indexes must be found
public static java.lang.Object castElement2Class(java.lang.Class elClazz,
java.lang.Object[] array)
elClazz - class of elements in the output arrayarray - input array
public static byte[] subarray(byte[] arr,
int beginIdx,
int endIdx)
throws java.lang.IllegalArgumentException
arr - input arraybeginIdx - if less then zero then assign to zeroendIdx - if more then arr.length() then assign to length
java.lang.IllegalArgumentException - if beginIdx > endIdxpublic static byte[] merge(byte[]... arrs)
arrs - array of array
public static byte[][] divide(byte[] arr,
int chunkSize)
throws java.lang.IllegalArgumentException
merge(byte[][]) to the result of
divide(byte[], int) then you obtain the source array. So this method is inverse of
merge(byte[][])
arr - big input arraychunkSize - the size of each resulting array (except, maybe, the last one)
java.lang.IllegalArgumentException - if chunkSize isn't positive
public static boolean equals(byte[][] a1,
byte[][] a2)
Arrays.equals(byte[], byte[]). Also true is
returned when both source arrays are null
a1 - a2 -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||