Class ArrayUtils
java.lang.Object
io.github.lukebemish.brainfrick.lang.ArrayUtils
Utility methods for using arrays from brainfrick. As brainfrick does not have dedicated array operations, the methods
in this class allow for creating, viewing, and modifying arrays.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
get
(boolean[] array, int index) Allows getting values from boolean arrays.static byte
get
(byte[] array, int index) Allows getting values from byte arrays.static char
get
(char[] array, int index) Allows getting values from char arrays.static double
get
(double[] array, int index) Allows getting values from double arrays.static float
get
(float[] array, int index) Allows getting values from float arrays.static int
get
(int[] array, int index) Allows getting values from int arrays.static long
get
(long[] array, int index) Allows getting values from long arrays.static short
get
(short[] array, int index) Allows getting values from short arrays.static <T> T
get
(T[] array, int index) Allows getting values from object arrays.static boolean[]
ofSizeBoolean
(int size) Creates an empty boolean array.static byte[]
ofSizeByte
(int size) Creates an empty byte array.static char[]
ofSizeChar
(int size) Creates an empty char array.static double[]
ofSizeDouble
(int size) Creates an empty double array.static float[]
ofSizeFloat
(int size) Creates an empty float array.static int[]
ofSizeInt
(int size) Creates an empty int array.static long[]
ofSizeLong
(int size) Creates an empty long array.static <T> T[]
ofSizeObject
(int size, Class<T> clazz) Creates an empty object array.static short[]
ofSizeShort
(int size) Creates an empty short array.static void
set
(boolean[] array, int index, boolean value) Allows setting of values in boolean arrays.static void
set
(byte[] array, int index, byte value) Allows setting of values in byte arrays.static void
set
(char[] array, int index, char value) Allows setting of values in char arrays.static void
set
(double[] array, int index, double value) Allows setting of values in double arrays.static void
set
(float[] array, int index, float value) Allows setting of values in float arrays.static void
set
(int[] array, int index, int value) Allows setting of values in int arrays.static void
set
(long[] array, int index, long value) Allows setting of values in long arrays.static void
set
(short[] array, int index, short value) Allows setting of values in short arrays.static <T> void
set
(T[] array, int index, T value) Allows setting of values in object arrays.static int
size
(boolean[] array) Allows getting the size of a boolean array.static int
size
(byte[] array) Allows getting the size of a byte array.static int
size
(char[] array) Allows getting the size of a char array.static int
size
(double[] array) Allows getting the size of a double array.static int
size
(float[] array) Allows getting the size of a float array.static int
size
(int[] array) Allows getting the size of an int array.static int
size
(long[] array) Allows getting the size of a long array.static int
size
(short[] array) Allows getting the size of a short array.static <T> int
size
(T[] array) Allows getting the size of an object array.
-
Constructor Details
-
ArrayUtils
public ArrayUtils()
-
-
Method Details
-
ofSizeInt
public static int[] ofSizeInt(int size) Creates an empty int array.- Parameters:
size
- The size array to create.- Returns:
- An empty int array of the provided size.
-
ofSizeShort
public static short[] ofSizeShort(int size) Creates an empty short array.- Parameters:
size
- The size array to create.- Returns:
- An empty short array of the provided size.
-
ofSizeByte
public static byte[] ofSizeByte(int size) Creates an empty byte array.- Parameters:
size
- The size array to create.- Returns:
- An empty byte array of the provided size.
-
ofSizeChar
public static char[] ofSizeChar(int size) Creates an empty char array.- Parameters:
size
- The size array to create.- Returns:
- An empty char array of the provided size.
-
ofSizeLong
public static long[] ofSizeLong(int size) Creates an empty long array.- Parameters:
size
- The size array to create.- Returns:
- An empty long array of the provided size.
-
ofSizeFloat
public static float[] ofSizeFloat(int size) Creates an empty float array.- Parameters:
size
- The size array to create.- Returns:
- An empty float array of the provided size.
-
ofSizeDouble
public static double[] ofSizeDouble(int size) Creates an empty double array.- Parameters:
size
- The size array to create.- Returns:
- An empty double array of the provided size.
-
ofSizeBoolean
public static boolean[] ofSizeBoolean(int size) Creates an empty boolean array.- Parameters:
size
- The size array to create.- Returns:
- An empty boolean array of the provided size.
-
ofSizeObject
Creates an empty object array.- Parameters:
size
- The size array to create.clazz
- theClass
of array to create.- Returns:
- An empty array of the provided size and class.
-
set
public static void set(int[] array, int index, int value) Allows setting of values in int arrays.- Parameters:
array
- The array to set a value in.index
- The index to set a value at.value
- The value to set at the provided index.
-
set
public static void set(short[] array, int index, short value) Allows setting of values in short arrays.- Parameters:
array
- The array to set a value in.index
- The index to set a value at.value
- The value to set at the provided index.
-
set
public static void set(byte[] array, int index, byte value) Allows setting of values in byte arrays.- Parameters:
array
- The array to set a value in.index
- The index to set a value at.value
- The value to set at the provided index.
-
set
public static void set(char[] array, int index, char value) Allows setting of values in char arrays.- Parameters:
array
- The array to set a value in.index
- The index to set a value at.value
- The value to set at the provided index.
-
set
public static void set(long[] array, int index, long value) Allows setting of values in long arrays.- Parameters:
array
- The array to set a value in.index
- The index to set a value at.value
- The value to set at the provided index.
-
set
public static void set(float[] array, int index, float value) Allows setting of values in float arrays.- Parameters:
array
- The array to set a value in.index
- The index to set a value at.value
- The value to set at the provided index.
-
set
public static void set(double[] array, int index, double value) Allows setting of values in double arrays.- Parameters:
array
- The array to set a value in.index
- The index to set a value at.value
- The value to set at the provided index.
-
set
public static void set(boolean[] array, int index, boolean value) Allows setting of values in boolean arrays.- Parameters:
array
- The array to set a value in.index
- The index to set a value at.value
- The value to set at the provided index.
-
set
public static <T> void set(T[] array, int index, T value) Allows setting of values in object arrays.- Parameters:
array
- The array to set a value in.index
- The index to set a value at.value
- The value to set at the provided index.
-
get
public static int get(int[] array, int index) Allows getting values from int arrays.- Parameters:
array
- The array to get a value from.index
- The index to get a value at.- Returns:
- The value at the provided index.
-
get
public static short get(short[] array, int index) Allows getting values from short arrays.- Parameters:
array
- The array to get a value from.index
- The index to get a value at.- Returns:
- The value at the provided index.
-
get
public static byte get(byte[] array, int index) Allows getting values from byte arrays.- Parameters:
array
- The array to get a value from.index
- The index to get a value at.- Returns:
- The value at the provided index.
-
get
public static char get(char[] array, int index) Allows getting values from char arrays.- Parameters:
array
- The array to get a value from.index
- The index to get a value at.- Returns:
- The value at the provided index.
-
get
public static long get(long[] array, int index) Allows getting values from long arrays.- Parameters:
array
- The array to get a value from.index
- The index to get a value at.- Returns:
- The value at the provided index.
-
get
public static float get(float[] array, int index) Allows getting values from float arrays.- Parameters:
array
- The array to get a value from.index
- The index to get a value at.- Returns:
- The value at the provided index.
-
get
public static double get(double[] array, int index) Allows getting values from double arrays.- Parameters:
array
- The array to get a value from.index
- The index to get a value at.- Returns:
- The value at the provided index.
-
get
public static boolean get(boolean[] array, int index) Allows getting values from boolean arrays.- Parameters:
array
- The array to get a value from.index
- The index to get a value at.- Returns:
- The value at the provided index.
-
get
public static <T> T get(T[] array, int index) Allows getting values from object arrays.- Parameters:
array
- The array to get a value from.index
- The index to get a value at.- Returns:
- The value at the provided index.
-
size
public static int size(int[] array) Allows getting the size of an int array.- Parameters:
array
- The array to get the size of.- Returns:
- The size of the array.
-
size
public static int size(short[] array) Allows getting the size of a short array.- Parameters:
array
- The array to get the size of.- Returns:
- The size of the array.
-
size
public static int size(byte[] array) Allows getting the size of a byte array.- Parameters:
array
- The array to get the size of.- Returns:
- The size of the array.
-
size
public static int size(char[] array) Allows getting the size of a char array.- Parameters:
array
- The array to get the size of.- Returns:
- The size of the array.
-
size
public static int size(long[] array) Allows getting the size of a long array.- Parameters:
array
- The array to get the size of.- Returns:
- The size of the array.
-
size
public static int size(float[] array) Allows getting the size of a float array.- Parameters:
array
- The array to get the size of.- Returns:
- The size of the array.
-
size
public static int size(double[] array) Allows getting the size of a double array.- Parameters:
array
- The array to get the size of.- Returns:
- The size of the array.
-
size
public static int size(boolean[] array) Allows getting the size of a boolean array.- Parameters:
array
- The array to get the size of.- Returns:
- The size of the array.
-
size
public static <T> int size(T[] array) Allows getting the size of an object array.- Parameters:
array
- The array to get the size of.- Returns:
- The size of the array.
-