Package com.inductiveautomation.rm.base
Class RMArrayUtils
java.lang.Object
com.inductiveautomation.rm.base.RMArrayUtils
A collection of array utility methods.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> T[]
add
(T[] anArray, T anObj) Adds a value to an array of objects.static <T> T[]
add
(T[] anArray, T anObj, int anIndex) Returns a new array by adding a value to an array of objects at the given index.static <T> T[]
addAll
(T[] anArray, T... theObjs) Returns an array by adding to the given array the given objects (array).static <T> T[]
addId
(T[] anArray, T anObj) Adds a value to an array of objects if list doesn't already contain it.static boolean
Returns whether the given array contains the given object.static <T> boolean
containsId
(T[] anArray, T aValue) Returns whether the given array contains the identical given object.static int[]
copyOfRange
(int[] anArray, int from, int to) Returns a copy of given range of given array (this method is in Java 6 Arrays class).static boolean
equals
(byte[] array1, byte[] array2) Returns whether two byte arrays are equal.static boolean
equals
(byte[] array1, byte[] array2, int length) Returns whether two byte arrays are equal to the given length.static boolean
equals
(float[] array1, float[] array2) Returns whether two float arrays are equal.static boolean
equals
(float[] array1, float[] array2, int length) Returns whether two float arrays are equal to the given length.static <T> T[]
Returns the individual object of a given class at given index (from all objects of given class).static <T> T
Returns the individual object of a given class at given index (from all objects of given class).static int
Returns the number of object in array of a given class.static int
Returns the index of the given object in the given array.static <T> int
indexOfId
(T[] anArray, T aValue) Returns the index of the given object in the given array using "==" instead of equals.static int
Returns the length of a given object array (or zero, if null).static <T> T[]
realloc
(T[] anArray, int aSize) Creates a new object array with original values and new size.static <T> T[]
remove
(T[] anArray, int anIndex) Returns a new array by removing a value from an array of objects at the given index.static <T> T[]
removeId
(T[] anArray, T anObj) Removes a value from an array of objects if list doesn't already contain it.static <T> T[]
replace
(T[] anArray, int start, int end, T... swapInArray) Replaces a range of values in an int array with values from another int array.static void
Reverse and array.
-
Constructor Details
-
RMArrayUtils
public RMArrayUtils()
-
-
Method Details
-
length
Returns the length of a given object array (or zero, if null). -
add
public static <T> T[] add(@Nonnull T[] anArray, @Nonnull T anObj) Adds a value to an array of objects. -
add
public static <T> T[] add(@Nonnull T[] anArray, @Nonnull T anObj, int anIndex) Returns a new array by adding a value to an array of objects at the given index. -
addAll
public static <T> T[] addAll(T[] anArray, T... theObjs) Returns an array by adding to the given array the given objects (array). -
remove
public static <T> T[] remove(T[] anArray, int anIndex) Returns a new array by removing a value from an array of objects at the given index. -
replace
public static <T> T[] replace(T[] anArray, int start, int end, T... swapInArray) Replaces a range of values in an int array with values from another int array. -
addId
public static <T> T[] addId(T[] anArray, T anObj) Adds a value to an array of objects if list doesn't already contain it. -
removeId
public static <T> T[] removeId(T[] anArray, T anObj) Removes a value from an array of objects if list doesn't already contain it. -
getCount
Returns the number of object in array of a given class. -
get
Returns the individual object of a given class at given index (from all objects of given class). -
get
Returns the individual object of a given class at given index (from all objects of given class). -
realloc
public static <T> T[] realloc(T[] anArray, int aSize) Creates a new object array with original values and new size. -
equals
public static boolean equals(byte[] array1, byte[] array2) Returns whether two byte arrays are equal. -
equals
public static boolean equals(byte[] array1, byte[] array2, int length) Returns whether two byte arrays are equal to the given length. -
equals
public static boolean equals(float[] array1, float[] array2) Returns whether two float arrays are equal. -
equals
public static boolean equals(float[] array1, float[] array2, int length) Returns whether two float arrays are equal to the given length. -
indexOf
Returns the index of the given object in the given array. -
contains
Returns whether the given array contains the given object. -
indexOfId
public static <T> int indexOfId(T[] anArray, T aValue) Returns the index of the given object in the given array using "==" instead of equals. -
containsId
public static <T> boolean containsId(T[] anArray, T aValue) Returns whether the given array contains the identical given object. -
copyOfRange
public static int[] copyOfRange(int[] anArray, int from, int to) Returns a copy of given range of given array (this method is in Java 6 Arrays class). -
reverse
Reverse and array.
-