# Class: com.pnfsoftware.jeb.util.collect.ArrayUtil

Utility methods for arrays.

## Static Field: NO_BOOLEAN
Type: `boolean[]`
Description: An empty immutable `boolean[]` array.

## Static Field: NO_BYTE
Type: `byte[]`
Description: An empty immutable `byte[]` array.

## Static Field: NO_CHAR
Type: `char[]`
Description: An empty immutable `char[]` array.

## Static Field: NO_DOUBLE
Type: `double[]`
Description: An empty immutable `double[]` array.

## Static Field: NO_FLOAT
Type: `float[]`
Description: An empty immutable `float[]` array.

## Static Field: NO_INT
Type: `int[]`
Description: An empty immutable `int[]` array.

## Static Field: NO_LONG
Type: `long[]`
Description: An empty immutable `long[]` array.

## Static Field: NO_OBJECT
Type: `java.lang.Object[]`
Description: An empty immutable [Object\[\]](Object) array.

## Static Field: NO_SHORT
Type: `short[]`
Description: An empty immutable `short[]` array.

## Static Field: NO_STRING
Type: `java.lang.String[]`
Description: An empty immutable [String\[\]](String) array.

## Static Method: asList
- parameter: `array`, type: `boolean[]`
- return type: `java.util.List<java.lang.Boolean>`

Description: A variant of [Arrays#asList(Object...)](Arrays#asList(Object...)) that accepts primitives.
parameter: array: input array
return: boxed list containing the array values

## Static Method: asList
- parameter: `array`, type: `byte[]`
- return type: `java.util.List<java.lang.Byte>`

Description: A variant of [Arrays#asList(Object...)](Arrays#asList(Object...)) that accepts primitives.
parameter: array: input array
return: boxed list containing the array values

## Static Method: asList
- parameter: `array`, type: `short[]`
- return type: `java.util.List<java.lang.Short>`

Description: A variant of [Arrays#asList(Object...)](Arrays#asList(Object...)) that accepts primitives.
parameter: array: input array
return: boxed list containing the array values

## Static Method: asList
- parameter: `array`, type: `char[]`
- return type: `java.util.List<java.lang.Character>`

Description: A variant of [Arrays#asList(Object...)](Arrays#asList(Object...)) that accepts primitives.
parameter: array: input array
return: boxed list containing the array values

## Static Method: asList
- parameter: `array`, type: `int[]`
- return type: `java.util.List<java.lang.Integer>`

Description: A variant of [Arrays#asList(Object...)](Arrays#asList(Object...)) that accepts primitives.
parameter: array: input array
return: boxed list containing the array values

## Static Method: asList
- parameter: `array`, type: `long[]`
- return type: `java.util.List<java.lang.Long>`

Description: A variant of [Arrays#asList(Object...)](Arrays#asList(Object...)) that accepts primitives.
parameter: array: input array
return: boxed list containing the array values

## Static Method: asList
- parameter: `array`, type: `float[]`
- return type: `java.util.List<java.lang.Float>`

Description: A variant of [Arrays#asList(Object...)](Arrays#asList(Object...)) that accepts primitives.
parameter: array: input array
return: boxed list containing the array values

## Static Method: asList
- parameter: `array`, type: `double[]`
- return type: `java.util.List<java.lang.Double>`

Description: A variant of [Arrays#asList(Object...)](Arrays#asList(Object...)) that accepts primitives.
parameter: array: input array
return: boxed list containing the array values

## Static Method: asView
- parameter: `a`, type: `T[]`
- return type: `java.util.List<T>`

Description: Provide a continuous read\-only view of an array.
parameter: T: element type
parameter: a: array \(non\-null\)
return: a read\-only list consisting of the elements of the first array

## Static Method: asView
- parameter: `a`, type: `T[]`
- parameter: `b`, type: `T[]`
- return type: `java.util.List<T>`

Description: Provide a continuous read\-only view of two arrays.
parameter: T: element type
parameter: a: first array \(non\-null\)
parameter: b: second array \(non\-null\)
return: a read\-only list consisting of the elements of the first array, followed by the         elements of the second array

## Static Method: asView
- parameter: `arrays`, type: `T[][]`
- return type: `java.util.List<T>`

Description: Provide a continuous read\-only view of an array of arrays. This method is well suited for 3\+ arrays. \` \*
parameter: T: element type
parameter: arrays: the arrays
return: a read\-only list consisting of the elements of the first array, followed by the         elements of the second array, etc.

## Static Method: bytesToIntegers
- parameter: `input`, type: `byte[]`
- return type: `int[]`

Description: Convert a byte array to an int array with the same exact values \(that means the bytes are sign extended\).
parameter: input: byte array
return: int array

## Static Method: checkOffsetAndCount
- parameter: `arrayLength`, type: `int`
- parameter: `offset`, type: `int`
- parameter: `count`, type: `int`

Description: Validate an array sub\-range.
parameter: arrayLength: array length
parameter: offset: sub\-range start offset
parameter: count: sub\-range element count

## Static Method: compareBytes
- parameter: `array1`, type: `byte[]`
- parameter: `pos1`, type: `int`
- parameter: `array2`, type: `byte[]`
- parameter: `pos2`, type: `int`
- parameter: `size`, type: `int`
- return type: `int`

Description: Compare arrays of bytes. This method raises an [ArrayIndexOutOfBoundsException](ArrayIndexOutOfBoundsException) exception if either one of the input arrays does not contain enough bytes to be compared.
parameter: array1: first array
parameter: pos1: where to start in the first array
parameter: array2: second array
parameter: pos2: where to start in the second array
parameter: size: number of bytes to be compared
return: standard \-1/0/\+1 comparison result

## Static Method: copyBytes
- parameter: `dst`, type: `byte[]`
- parameter: `dstOffset`, type: `int`
- parameter: `src`, type: `byte[]`
- parameter: `srcOffset`, type: `int`
- parameter: `size`, type: `int`

Description: Wrapper around [Java's arraycopy\(\)](System#arraycopy(Object, int, Object, int, int)). 

 Copy bytes from a source to a destination. If the destination and source arrays are the same, potential overlaps are properly handled. This method does not validate bounds or arguments: [NullPointerException](NullPointerException) and [ArrayIndexOutOfBoundsException](ArrayIndexOutOfBoundsException) can be raised.
parameter: dst: destination array
parameter: dstOffset: start offset in the destination array
parameter: src: source array source array, potentially the same as the destination array
parameter: srcOffset: start offset in the source array
parameter: size: number of bytes to be copied

## Static Method: equalsBytes
- parameter: `array1`, type: `byte[]`
- parameter: `pos1`, type: `int`
- parameter: `array2`, type: `byte[]`
- parameter: `pos2`, type: `int`
- parameter: `size`, type: `int`
- return type: `boolean`

Description: An extended version of [Arrays#equals(boolean[], boolean[])](Arrays#equals(boolean[], boolean[])).
parameter: array1: first array
parameter: pos1: start offset in the first array
parameter: array2: second array
parameter: pos2: start offset in the second array
parameter: size: number of bytes to compare
return: true if the requested ranges are valid and equal

## Static Method: find
- parameter: `array`, type: `boolean[]`
- parameter: `value`, type: `boolean`
- return type: `int`

Description: Find the first index of a value in an array.
parameter: array: input array
parameter: value: value to find
return: zero\-based index, or \-1 if absent

## Static Method: find
- parameter: `array`, type: `byte[]`
- parameter: `value`, type: `byte`
- return type: `int`

Description: Find the first index of a value in an array.
parameter: array: input array
parameter: value: value to find
return: zero\-based index, or \-1 if absent

## Static Method: find
- parameter: `array`, type: `char[]`
- parameter: `value`, type: `char`
- return type: `int`

Description: Find the first index of a value in an array.
parameter: array: input array
parameter: value: value to find
return: zero\-based index, or \-1 if absent

## Static Method: find
- parameter: `array`, type: `short[]`
- parameter: `value`, type: `short`
- return type: `int`

Description: Find the first index of a value in an array.
parameter: array: input array
parameter: value: value to find
return: zero\-based index, or \-1 if absent

## Static Method: find
- parameter: `array`, type: `int[]`
- parameter: `value`, type: `int`
- return type: `int`

Description: Find the first index of a value in an array.
parameter: array: input array
parameter: value: value to find
return: zero\-based index, or \-1 if absent

## Static Method: find
- parameter: `array`, type: `long[]`
- parameter: `value`, type: `long`
- return type: `int`

Description: Find the first index of a value in an array.
parameter: array: input array
parameter: value: value to find
return: zero\-based index, or \-1 if absent

## Static Method: find
- parameter: `array`, type: `float[]`
- parameter: `value`, type: `float`
- return type: `int`

Description: Find the first index of a value in an array.
parameter: array: input array
parameter: value: value to find
return: zero\-based index, or \-1 if absent

## Static Method: find
- parameter: `array`, type: `double[]`
- parameter: `value`, type: `double`
- return type: `int`

Description: Find the first index of a value in an array.
parameter: array: input array
parameter: value: value to find
return: zero\-based index, or \-1 if absent

## Static Method: findByEquality
- parameter: `array`, type: `java.lang.Object[]`
- parameter: `value`, type: `java.lang.Object`
- return type: `int`

Description: Find the first index of an object by [Object#equals(Object)](Object#equals(Object)).
parameter: array: input array
parameter: value: value to find
return: zero\-based index, or \-1 if absent

## Static Method: findByReference
- parameter: `array`, type: `java.lang.Object[]`
- parameter: `value`, type: `java.lang.Object`
- return type: `int`

Description: Find the first index of an object by reference equality.
parameter: array: input array
parameter: value: value to find
return: zero\-based index, or \-1 if absent

## Static Method: getSafe
- parameter: `array`, type: `T[]`
- parameter: `index`, type: `int`
- parameter: `defaultValue`, type: `T`
- return type: `T`

Description: Retrieve a value from an array, or default value if index is out of bound or value from array is null.
parameter: T: Any [Object](Object)
parameter: array: the array
parameter: index: the index of the array
parameter: defaultValue: default value to return in case of error
return: the element of the array at the index or the default value

## Static Method: getSafe2
- parameter: `array`, type: `T[][]`
- parameter: `index`, type: `int`
- parameter: `index2`, type: `int`
- parameter: `defaultValue`, type: `T`
- return type: `T`

Description: Retrieve a value from a 2 dimension array, or default value if index is out of bound \(from any array\) or value from array is null. This is an equivalent of getSafe\(getSafe\(array, index, new T\[\]{}\), index2, default\)
parameter: T: Any [Object](Object)
parameter: array: the array
parameter: index: the index of the first array
parameter: index2: the index of the second array
parameter: defaultValue: default value to return in case of error
return: the element of the array at the index or the default value

## Static Method: getSafe3
- parameter: `array`, type: `T[][][]`
- parameter: `index`, type: `int`
- parameter: `index2`, type: `int`
- parameter: `index3`, type: `int`
- parameter: `defaultValue`, type: `T`
- return type: `T`

Description: Retrieve a value from a 3\-dimensional array, or a default value if an index is out of bound or an intermediate array/value is null.
parameter: T: Any [Object](Object)
parameter: array: the array
parameter: index: the index of the first array
parameter: index2: the index of the second array
parameter: index3: the index of the third array
parameter: defaultValue: default value to return in case of error
return: the element of the array at the index or the default value

## Static Method: indexOf
- parameter: `haystack`, type: `byte[]`
- parameter: `haybeg`, type: `int`
- parameter: `hayend`, type: `int`
- parameter: `needle`, type: `byte[]`
- parameter: `beg`, type: `int`
- parameter: `end`, type: `int`
- return type: `int`

Description: Search for a needle in a haystack.
parameter: haystack: array to be searched
parameter: haybeg: start index in haystack
parameter: hayend: end index in haystack \(exclusive\)
parameter: needle: bytes to search in the haystack
parameter: beg: start index in needle
parameter: end: end index in needle \(exclusive\)
return: the index of the first needle found in haystack; \-1 if not found

## Static Method: integersToBytes
- parameter: `input`, type: `int[]`
- return type: `byte[]`

Description: Convert an int array into a byte array by casting all integers to bytes.
parameter: input: int array
return: byte array

## Static Method: isSled
- parameter: `array`, type: `byte[]`
- parameter: `value`, type: `byte`
- return type: `boolean`

Description: Check if an array contains a same repeated value.
parameter: array: the array to be checked
parameter: value: the sled value
return: true if all bytes in the array are equal to the provided value

## Static Method: swap
- parameter: `array`, type: `boolean[]`
- parameter: `offset`, type: `int`
- parameter: `size`, type: `int`

Description: Flip the order of an array of booleans.
parameter: array: array to reverse
parameter: offset: first index to reverse
parameter: size: number of elements to reverse

## Static Method: swap
- parameter: `array`, type: `boolean[]`

Description: Flip the order of an array of booleans.
parameter: array: array to reverse

## Static Method: swap
- parameter: `array`, type: `byte[]`
- parameter: `offset`, type: `int`
- parameter: `size`, type: `int`

Description: Flip the order of an array of bytes.
parameter: array: array to reverse
parameter: offset: first index to reverse
parameter: size: number of elements to reverse

## Static Method: swap
- parameter: `array`, type: `byte[]`

Description: Flip the order of an array of bytes.
parameter: array: array to reverse

## Static Method: swap
- parameter: `array`, type: `short[]`
- parameter: `offset`, type: `int`
- parameter: `size`, type: `int`

Description: Flip the order of an array of shorts.
parameter: array: array to reverse
parameter: offset: first index to reverse
parameter: size: number of elements to reverse

## Static Method: swap
- parameter: `array`, type: `short[]`

Description: Flip the order of an array of shorts.
parameter: array: array to reverse

## Static Method: swap
- parameter: `array`, type: `char[]`
- parameter: `offset`, type: `int`
- parameter: `size`, type: `int`

Description: Flip the order of an array of chars.
parameter: array: array to reverse
parameter: offset: first index to reverse
parameter: size: number of elements to reverse

## Static Method: swap
- parameter: `array`, type: `char[]`

Description: Flip the order of an array of chars.
parameter: array: array to reverse

## Static Method: swap
- parameter: `array`, type: `int[]`
- parameter: `offset`, type: `int`
- parameter: `size`, type: `int`

Description: Flip the order of an array of ints.
parameter: array: array to reverse
parameter: offset: first index to reverse
parameter: size: number of elements to reverse

## Static Method: swap
- parameter: `array`, type: `int[]`

Description: Flip the order of an array of ints.
parameter: array: array to reverse

## Static Method: swap
- parameter: `array`, type: `long[]`
- parameter: `offset`, type: `int`
- parameter: `size`, type: `int`

Description: Flip the order of an array of longs.
parameter: array: array to reverse
parameter: offset: first index to reverse
parameter: size: number of elements to reverse

## Static Method: swap
- parameter: `array`, type: `long[]`

Description: Flip the order of an array of longs.
parameter: array: array to reverse

## Static Method: swap
- parameter: `array`, type: `float[]`
- parameter: `offset`, type: `int`
- parameter: `size`, type: `int`

Description: Flip the order of an array of floats.
parameter: array: array to reverse
parameter: offset: first index to reverse
parameter: size: number of elements to reverse

## Static Method: swap
- parameter: `array`, type: `float[]`

Description: Flip the order of an array of floats.
parameter: array: array to reverse

## Static Method: swap
- parameter: `array`, type: `double[]`
- parameter: `offset`, type: `int`
- parameter: `size`, type: `int`

Description: Flip the order of an array of doubles.
parameter: array: array to reverse
parameter: offset: first index to reverse
parameter: size: number of elements to reverse

## Static Method: swap
- parameter: `array`, type: `double[]`

Description: Flip the order of an array of doubles.
parameter: array: array to reverse

## Static Method: swap
- parameter: `array`, type: `T[]`
- parameter: `offset`, type: `int`
- parameter: `size`, type: `int`

Description: Flip the order of an array of generic objects.
parameter: T: element type
parameter: array: array to reverse
parameter: offset: first index to reverse
parameter: size: number of elements to reverse

## Static Method: swap
- parameter: `array`, type: `T[]`

Description: Flip the order of an array of generic objects.
parameter: T: element type
parameter: array: array to reverse

## Static Method: unsignedBytesToIntegers
- parameter: `input`, type: `byte[]`
- return type: `int[]`

Description: Convert an array of **unsigned** bytes to an array of integers.
parameter: input: byte array, for which the bytes are treated as unsigned
return: int array

