Package utilities.util
Class ArrayUtilities
- java.lang.Object
-
- utilities.util.ArrayUtilities
-
public final class ArrayUtilities extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description ArrayUtilities()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanarrayRangesEquals(byte[] b1, int start_b1, byte[] b2, int start_b2, int len)Returns true if a portion of byte array b1 equals an equally sized portion of byte array b2.static intcompare(byte[] a, byte[] b)Compare two byte arrays by their corresponding entries If the two arrays have differing lengths, the shorter precedes the longer.static <T> T[]copyAndAppend(T[] array, T element)Returns a copy of the given array with the provided element appended.static booleanisArrayPrimativeEqual(java.lang.Object o1, java.lang.Object o2)Compares two primitive arrays for equalitystatic byte[]reverse(byte[] array)Returns a new copy of the specified bytearraywith the elements in reversed order.
-
-
-
Method Detail
-
reverse
public static byte[] reverse(byte[] array)
Returns a new copy of the specified bytearraywith the elements in reversed order.- Parameters:
array- byte array to reverse- Returns:
- new array instance with elements in reverse order
-
isArrayPrimativeEqual
public static boolean isArrayPrimativeEqual(java.lang.Object o1, java.lang.Object o2)Compares two primitive arrays for equality- Parameters:
o1- the first arrayo2- the second array- Returns:
- true if each element of the array is equal
- Throws:
java.lang.IllegalArgumentException- if either argument is not an array
-
arrayRangesEquals
public static boolean arrayRangesEquals(byte[] b1, int start_b1, byte[] b2, int start_b2, int len)Returns true if a portion of byte array b1 equals an equally sized portion of byte array b2.If the sizes of b1 or b2 do not allow for a full comparison of
lenbytes, this function will return false.- Parameters:
b1- first byte arraystart_b1- offset to start comparison in b1b2- second byte arraystart_b2- offset to start comparison in b2len- number of bytes to compare- Returns:
- true or false if the portion is equal
-
copyAndAppend
public static <T> T[] copyAndAppend(T[] array, T element)Returns a copy of the given array with the provided element appended. The length of the returned array will be one element greater than the given array.- Parameters:
array- The array to copy.element- The element to append to the copy.- Returns:
- A copy of the given array with the provided element appended.
-
compare
public static int compare(byte[] a, byte[] b)Compare two byte arrays by their corresponding entries If the two arrays have differing lengths, the shorter precedes the longer. Otherwise, they are compared as in C'smemcmp, except that Javabytes are signed.- Parameters:
a- the first arrayb- the second array- Returns:
- a comparison result as in
Comparable.compareTo(Object)
-
-