Package com.github.tommyettinger.digital
Class ArrayTools
java.lang.Object
com.github.tommyettinger.digital.ArrayTools
Static methods for various frequently-used operations on 1D and 2D arrays. Has methods for copying, inserting, and
filling 2D arrays of primitive types (char, int, float, double, and boolean). Has a few methods for creating ranges
of ints or chars easily as 1D arrays.
-
Method Summary
Modifier and TypeMethodDescriptionstatic char[]
charSpan
(char start, char end) Stupidly simple convenience method that produces a char range from start to end, including end, as a char array.static boolean[][]
copy
(boolean[][] source) Gets a copy of the 2D boolean array, source, that has the same data but shares no references with source.static char[][]
copy
(char[][] source) Gets a copy of the 2D char array, source, that has the same data but shares no references with source.static double[][]
copy
(double[][] source) Gets a copy of the 2D double array, source, that has the same data but shares no references with source.static float[][]
copy
(float[][] source) Gets a copy of the 2D float array, source, that has the same data but shares no references with source.static int[][]
copy
(int[][] source) Gets a copy of the 2D int array, source, that has the same data but shares no references with source.static long[][]
copy
(long[][] source) Gets a copy of the 2D long array, source, that has the same data but shares no references with source.static void
fill
(boolean[][] array2d, boolean value) Fillsarray2d
withvalue
.static void
fill
(boolean[][] array2d, boolean value, int startX, int startY, int endX, int endY) Fills a sub-section ofarray2d
withvalue
, with the section defined by start/end x/y.static boolean[][]
fill
(boolean contents, int width, int height) Creates a 2D array of the given width and height, filled with entirely with the value contents.static void
fill
(byte[][] array2d, byte value) Fillsarray2d
withvalue
.static byte[][]
fill
(byte contents, int width, int height) Creates a 2D array of the given width and height, filled with entirely with the value contents.static void
fill
(char[][] array2d, char value) Fillsarray2d
withvalue
.static void
fill
(char[][] array2d, char value, int startX, int startY, int endX, int endY) Fills a sub-section ofarray2d
withvalue
, with the section defined by start/end x/y.static char[][]
fill
(char contents, int width, int height) Creates a 2D array of the given width and height, filled with entirely with the value contents.static void
fill
(double[][] array2d, double value) Fillsarray2d
withvalue
.static void
fill
(double[][] array2d, double value, int startX, int startY, int endX, int endY) Fills a sub-section ofarray2d
withvalue
, with the section defined by start/end x/y.static double[][]
fill
(double contents, int width, int height) Creates a 2D array of the given width and height, filled with entirely with the value contents.static void
fill
(float[][] array2d, float value) Fillsarray2d
withvalue
.static void
fill
(float[][] array2d, float value, int startX, int startY, int endX, int endY) Fills a sub-section ofarray2d
withvalue
, with the section defined by start/end x/y.static float[][]
fill
(float contents, int width, int height) Creates a 2D array of the given width and height, filled with entirely with the value contents.static void
fill
(int[][] array2d, int value) Fillsarray2d
withvalue
.static void
fill
(int[][] array2d, int value, int startX, int startY, int endX, int endY) Fills a sub-section ofarray2d
withvalue
, with the section defined by start/end x/y.static int[][]
fill
(int contents, int width, int height) Creates a 2D array of the given width and height, filled with entirely with the value contents.static void
fill
(long[][] array2d, long value) Fillsarray2d
withvalue
.static void
fill
(long[][] array2d, long value, int startX, int startY, int endX, int endY) Fills a sub-section ofarray2d
withvalue
, with the section defined by start/end x/y.static long[][]
fill
(long contents, int width, int height) Creates a 2D array of the given width and height, filled with entirely with the value contents.static <T> void
fill
(T[][] array2d, T value) Fillsarray2d
with identical references tovalue
(not copies).static <T> void
fill
(T[][] array2d, T value, int startX, int startY, int endX, int endY) Fills a sub-section ofarray2d
with identical references tovalue
(not copies), with the section defined by start/end x/y.static void
fill3D
(boolean[][][] array3d, boolean value) Fillsarray3d
withvalue
.static void
fill3D
(byte[][][] array3d, byte value) Fillsarray3d
withvalue
.static void
fill3D
(char[][][] array3d, char value) Fillsarray3d
withvalue
.static void
fill3D
(double[][][] array3d, double value) Fillsarray3d
withvalue
.static void
fill3D
(float[][][] array3d, float value) Fillsarray3d
withvalue
.static void
fill3D
(int[][][] array3d, int value) Fillsarray3d
withvalue
.static void
fill3D
(long[][][] array3d, long value) Fillsarray3d
withvalue
.static <T> void
fill3D
(T[][][] array3d, T value) Fillsarray3d
with identical references tovalue
(not copies).static boolean[][]
insert
(boolean[][] source, boolean[][] target, int x, int y) Inserts as much of source into target at the given x,y position as target can hold or source can supply.static char[][]
insert
(char[][] source, char[][] target, int x, int y) Inserts as much of source into target at the given x,y position as target can hold or source can supply.static double[][]
insert
(double[][] source, double[][] target, int x, int y) Inserts as much of source into target at the given x,y position as target can hold or source can supply.static float[][]
insert
(float[][] source, float[][] target, int x, int y) Inserts as much of source into target at the given x,y position as target can hold or source can supply.static int[][]
insert
(int[][] source, int[][] target, int x, int y) Inserts as much of source into target at the given x,y position as target can hold or source can supply.static long[][]
insert
(long[][] source, long[][] target, int x, int y) Inserts as much of source into target at the given x,y position as target can hold or source can supply.static <T> T[][]
insert
(T[][] source, T[][] target, int x, int y) Inserts as much of source into target at the given x,y position as target can hold or source can supply.static char
letterAt
(int index) Gets the nth letter from the set of 256 visually distinct glyphs; from index 0 (returning 'A') to 255 (returning the Greek lower-case letter gamma, 'γ') and wrapping around if given negative numbers or numbers larger than 255.static char[]
letterSpan
(int charCount) Stupidly simple convenience method that produces a char array containing only letters that can be reasonably displayed with many fonts.static int[]
range
(int end) Stupidly simple convenience method that produces a range from 0 to end, not including end, as an int array.static int[]
range
(int[] buffer) Fills the given int array with sequential ints from 0 tobuffer.length - 1
.static int[]
range
(int start, int end) Stupidly simple convenience method that produces a range from start to end, not including end, as an int array.static boolean[]
reverse
(boolean[] data) Reverses the array given as a parameter, in-place, and returns the modified original.static byte[]
reverse
(byte[] data) Reverses the array given as a parameter, in-place, and returns the modified original.static char[]
reverse
(char[] data) Reverses the array given as a parameter, in-place, and returns the modified original.static double[]
reverse
(double[] data) Reverses the array given as a parameter, in-place, and returns the modified original.static float[]
reverse
(float[] data) Reverses the array given as a parameter, in-place, and returns the modified original.static int[]
reverse
(int[] data) Reverses the array given as a parameter, in-place, and returns the modified original.static long[]
reverse
(long[] data) Reverses the array given as a parameter, in-place, and returns the modified original.static <T> T[]
reverse
(T[] data) Reverses the array given as a parameter, in-place, and returns the modified original.static boolean[][]
set
(boolean[][] source, boolean[][] target) Takes a 2D source array and sets it into a 2D target array, as much as target can hold or source can supply.static char[][]
set
(char[][] source, char[][] target) Takes a 2D source array and sets it into a 2D target array, as much as target can hold or source can supply.static double[][]
set
(double[][] source, double[][] target) Takes a 2D source array and sets it into a 2D target array, as much as target can hold or source can supply.static float[][]
set
(float[][] source, float[][] target) Takes a 2D source array and sets it into a 2D target array, as much as target can hold or source can supply.static int[][]
set
(int[][] source, int[][] target) Takes a 2D source array and sets it into a 2D target array, as much as target can hold or source can supply.static long[][]
set
(long[][] source, long[][] target) Takes a 2D source array and sets it into a 2D target array, as much as target can hold or source can supply.static <T> T[][]
set
(T[][] source, T[][] target) Takes a 2D source array and sets it into a 2D target array, as much as target can hold or source can supply.
-
Method Details
-
range
public static int[] range(int end) Stupidly simple convenience method that produces a range from 0 to end, not including end, as an int array.- Parameters:
end
- the exclusive upper bound on the range- Returns:
- the range of ints as an int array
-
range
public static int[] range(int[] buffer) Fills the given int array with sequential ints from 0 tobuffer.length - 1
.- Parameters:
buffer
- an int array that will be modified in-place; if null this returns null- Returns:
- buffer, after modifications
-
range
public static int[] range(int start, int end) Stupidly simple convenience method that produces a range from start to end, not including end, as an int array.- Parameters:
start
- the inclusive lower bound on the rangeend
- the exclusive upper bound on the range- Returns:
- the range of ints as an int array
-
charSpan
public static char[] charSpan(char start, char end) Stupidly simple convenience method that produces a char range from start to end, including end, as a char array.- Parameters:
start
- the inclusive lower bound on the range, such as 'a'end
- the inclusive upper bound on the range, such as 'z'- Returns:
- the range of chars as a char array
-
letterSpan
public static char[] letterSpan(int charCount) Stupidly simple convenience method that produces a char array containing only letters that can be reasonably displayed with many fonts. The letters are copied from a single source of 256 chars; if you need more chars or you don't need pure letters, you can usecharSpan(char, char)
. This set does not contain "visual duplicate" letters, such as Latin alphabet capital letter 'A' and Greek alphabet capital letter alpha, 'Α'; it does contain many accented Latin letters and the visually-distinct Greek letters, up to a point.- Parameters:
charCount
- the number of letters to return in an array; the maximum this will produce is 256- Returns:
- the range of letters as a char array
-
letterAt
public static char letterAt(int index) Gets the nth letter from the set of 256 visually distinct glyphs; from index 0 (returning 'A') to 255 (returning the Greek lower-case letter gamma, 'γ') and wrapping around if given negative numbers or numbers larger than 255. This set does not contain "visual duplicate" letters, such as Latin alphabet capital letter 'A' and Greek alphabet capital letter alpha, 'Α'; it does contain many accented Latin letters and the visually-distinct Greek letters, up to a point.- Parameters:
index
- typically from 0 to 255, but all ints are allowed and will produce letters- Returns:
- the letter at the given index in a 256-element portion of visually distinct letters
-
copy
public static char[][] copy(char[][] source) Gets a copy of the 2D char array, source, that has the same data but shares no references with source.- Parameters:
source
- a 2D char array- Returns:
- a copy of source, or null if source is null
-
copy
public static double[][] copy(double[][] source) Gets a copy of the 2D double array, source, that has the same data but shares no references with source.- Parameters:
source
- a 2D double array- Returns:
- a copy of source, or null if source is null
-
copy
public static float[][] copy(float[][] source) Gets a copy of the 2D float array, source, that has the same data but shares no references with source.- Parameters:
source
- a 2D float array- Returns:
- a copy of source, or null if source is null
-
copy
public static int[][] copy(int[][] source) Gets a copy of the 2D int array, source, that has the same data but shares no references with source.- Parameters:
source
- a 2D int array- Returns:
- a copy of source, or null if source is null
-
copy
public static long[][] copy(long[][] source) Gets a copy of the 2D long array, source, that has the same data but shares no references with source.- Parameters:
source
- a 2D long array- Returns:
- a copy of source, or null if source is null
-
copy
public static boolean[][] copy(boolean[][] source) Gets a copy of the 2D boolean array, source, that has the same data but shares no references with source.- Parameters:
source
- a 2D boolean array- Returns:
- a copy of source, or null if source is null
-
insert
public static char[][] insert(char[][] source, char[][] target, int x, int y) Inserts as much of source into target at the given x,y position as target can hold or source can supply. Modifies target in-place and also returns target for chaining. Used primarily to place a smaller array into a different position in a larger array, often freshly allocated.- Parameters:
source
- a 2D char array that will be copied and inserted into targettarget
- a 2D char array that will be modified by receiving as much of source as it can holdx
- the x position in target to receive the items from the first cell in sourcey
- the y position in target to receive the items from the first cell in source- Returns:
- target, modified, with source inserted into it at the given position
-
insert
public static double[][] insert(double[][] source, double[][] target, int x, int y) Inserts as much of source into target at the given x,y position as target can hold or source can supply. Modifies target in-place and also returns target for chaining. Used primarily to place a smaller array into a different position in a larger array, often freshly allocated.- Parameters:
source
- a 2D double array that will be copied and inserted into targettarget
- a 2D double array that will be modified by receiving as much of source as it can holdx
- the x position in target to receive the items from the first cell in sourcey
- the y position in target to receive the items from the first cell in source- Returns:
- target, modified, with source inserted into it at the given position
-
insert
public static float[][] insert(float[][] source, float[][] target, int x, int y) Inserts as much of source into target at the given x,y position as target can hold or source can supply. Modifies target in-place and also returns target for chaining. Used primarily to place a smaller array into a different position in a larger array, often freshly allocated.- Parameters:
source
- a 2D float array that will be copied and inserted into targettarget
- a 2D float array that will be modified by receiving as much of source as it can holdx
- the x position in target to receive the items from the first cell in sourcey
- the y position in target to receive the items from the first cell in source- Returns:
- target, modified, with source inserted into it at the given position
-
insert
public static int[][] insert(int[][] source, int[][] target, int x, int y) Inserts as much of source into target at the given x,y position as target can hold or source can supply. Modifies target in-place and also returns target for chaining. Used primarily to place a smaller array into a different position in a larger array, often freshly allocated.- Parameters:
source
- a 2D int array that will be copied and inserted into targettarget
- a 2D int array that will be modified by receiving as much of source as it can holdx
- the x position in target to receive the items from the first cell in sourcey
- the y position in target to receive the items from the first cell in source- Returns:
- target, modified, with source inserted into it at the given position
-
insert
public static long[][] insert(long[][] source, long[][] target, int x, int y) Inserts as much of source into target at the given x,y position as target can hold or source can supply. Modifies target in-place and also returns target for chaining. Used primarily to place a smaller array into a different position in a larger array, often freshly allocated.- Parameters:
source
- a 2D long array that will be copied and inserted into targettarget
- a 2D long array that will be modified by receiving as much of source as it can holdx
- the x position in target to receive the items from the first cell in sourcey
- the y position in target to receive the items from the first cell in source- Returns:
- target, modified, with source inserted into it at the given position
-
insert
public static boolean[][] insert(boolean[][] source, boolean[][] target, int x, int y) Inserts as much of source into target at the given x,y position as target can hold or source can supply. Modifies target in-place and also returns target for chaining. Used primarily to place a smaller array into a different position in a larger array, often freshly allocated.- Parameters:
source
- a 2D boolean array that will be copied and inserted into targettarget
- a 2D boolean array that will be modified by receiving as much of source as it can holdx
- the x position in target to receive the items from the first cell in sourcey
- the y position in target to receive the items from the first cell in source- Returns:
- target, modified, with source inserted into it at the given position
-
insert
public static <T> T[][] insert(T[][] source, T[][] target, int x, int y) Inserts as much of source into target at the given x,y position as target can hold or source can supply. Modifies target in-place and also returns target for chaining. Used primarily to place a smaller array into a different position in a larger array, often freshly allocated. This does not create copies of any T items;source
will reference the same T items astarget
.- Parameters:
source
- a 2D generic array that will be copied and inserted into targettarget
- a 2D generic array that will be modified by receiving as much of source as it can holdx
- the x position in target to receive the items from the first cell in sourcey
- the y position in target to receive the items from the first cell in source- Returns:
- target, modified, with source inserted into it at the given position
-
set
public static char[][] set(char[][] source, char[][] target) Takes a 2D source array and sets it into a 2D target array, as much as target can hold or source can supply. Modifies target in-place and also returns target for chaining. This is just likeinsert(char[][], char[][], int, int)
with x and y both always 0, but does slightly less math per call, and can be clearer as to the intent of the method.- Parameters:
source
- a 2D char array that will be copied and inserted into targettarget
- a 2D char array that will be modified by receiving as much of source as it can hold- Returns:
- target, modified, with the values from source set as much as possible
-
set
public static float[][] set(float[][] source, float[][] target) Takes a 2D source array and sets it into a 2D target array, as much as target can hold or source can supply. Modifies target in-place and also returns target for chaining. This is just likeinsert(float[][], float[][], int, int)
with x and y both always 0, but does slightly less math per call, and can be clearer as to the intent of the method.- Parameters:
source
- a 2D float array that will be copied and inserted into targettarget
- a 2D float array that will be modified by receiving as much of source as it can hold- Returns:
- target, modified, with the values from source set as much as possible
-
set
public static double[][] set(double[][] source, double[][] target) Takes a 2D source array and sets it into a 2D target array, as much as target can hold or source can supply. Modifies target in-place and also returns target for chaining. This is just likeinsert(double[][], double[][], int, int)
with x and y both always 0, but does slightly less math per call, and can be clearer as to the intent of the method.- Parameters:
source
- a 2D double array that will be copied and inserted into targettarget
- a 2D double array that will be modified by receiving as much of source as it can hold- Returns:
- target, modified, with the values from source set as much as possible
-
set
public static int[][] set(int[][] source, int[][] target) Takes a 2D source array and sets it into a 2D target array, as much as target can hold or source can supply. Modifies target in-place and also returns target for chaining. This is just likeinsert(int[][], int[][], int, int)
with x and y both always 0, but does slightly less math per call, and can be clearer as to the intent of the method.- Parameters:
source
- a 2D int array that will be copied and inserted into targettarget
- a 2D int array that will be modified by receiving as much of source as it can hold- Returns:
- target, modified, with the values from source set as much as possible
-
set
public static long[][] set(long[][] source, long[][] target) Takes a 2D source array and sets it into a 2D target array, as much as target can hold or source can supply. Modifies target in-place and also returns target for chaining. This is just likeinsert(long[][], long[][], int, int)
with x and y both always 0, but does slightly less math per call, and can be clearer as to the intent of the method.- Parameters:
source
- a 2D long array that will be copied and inserted into targettarget
- a 2D long array that will be modified by receiving as much of source as it can hold- Returns:
- target, modified, with the values from source set as much as possible
-
set
public static boolean[][] set(boolean[][] source, boolean[][] target) Takes a 2D source array and sets it into a 2D target array, as much as target can hold or source can supply. Modifies target in-place and also returns target for chaining. This is just likeinsert(boolean[][], boolean[][], int, int)
with x and y both always 0, but does slightly less math per call, and can be clearer as to the intent of the method.- Parameters:
source
- a 2D boolean array that will be copied and inserted into targettarget
- a 2D boolean array that will be modified by receiving as much of source as it can hold- Returns:
- target, modified, with the values from source set as much as possible
-
set
public static <T> T[][] set(T[][] source, T[][] target) Takes a 2D source array and sets it into a 2D target array, as much as target can hold or source can supply. Modifies target in-place and also returns target for chaining. This is just likeinsert(Object[][], Object[][], int, int)
with x and y both always 0, but does slightly less math per call, and can be clearer as to the intent of the method. This does not create copies of any T items;source
will reference the same T items astarget
.- Parameters:
source
- a 2D generic array that will be copied and inserted into targettarget
- a 2D generic array that will be modified by receiving as much of source as it can hold- Returns:
- target, modified, with the values from source set as much as possible
-
fill
public static char[][] fill(char contents, int width, int height) Creates a 2D array of the given width and height, filled with entirely with the value contents. You may want to usefill(char[][], char)
to modify an existing 2D array instead.- Parameters:
contents
- the value to fill the array withwidth
- the desired widthheight
- the desired height- Returns:
- a freshly allocated 2D array of the requested dimensions, filled entirely with contents
-
fill
public static float[][] fill(float contents, int width, int height) Creates a 2D array of the given width and height, filled with entirely with the value contents. You may want to usefill(float[][], float)
to modify an existing 2D array instead.- Parameters:
contents
- the value to fill the array withwidth
- the desired widthheight
- the desired height- Returns:
- a freshly allocated 2D array of the requested dimensions, filled entirely with contents
-
fill
public static double[][] fill(double contents, int width, int height) Creates a 2D array of the given width and height, filled with entirely with the value contents. You may want to usefill(double[][], double)
to modify an existing 2D array instead.- Parameters:
contents
- the value to fill the array withwidth
- the desired widthheight
- the desired height- Returns:
- a freshly allocated 2D array of the requested dimensions, filled entirely with contents
-
fill
public static int[][] fill(int contents, int width, int height) Creates a 2D array of the given width and height, filled with entirely with the value contents. You may want to usefill(int[][], int)
to modify an existing 2D array instead.- Parameters:
contents
- the value to fill the array withwidth
- the desired widthheight
- the desired height- Returns:
- a freshly allocated 2D array of the requested dimensions, filled entirely with contents
-
fill
public static long[][] fill(long contents, int width, int height) Creates a 2D array of the given width and height, filled with entirely with the value contents. You may want to usefill(long[][], long)
to modify an existing 2D array instead.- Parameters:
contents
- the value to fill the array withwidth
- the desired widthheight
- the desired height- Returns:
- a freshly allocated 2D array of the requested dimensions, filled entirely with contents
-
fill
public static byte[][] fill(byte contents, int width, int height) Creates a 2D array of the given width and height, filled with entirely with the value contents. You may want to usefill(byte[][], byte)
to modify an existing 2D array instead.- Parameters:
contents
- the value to fill the array withwidth
- the desired widthheight
- the desired height- Returns:
- a freshly allocated 2D array of the requested dimensions, filled entirely with contents
-
fill
public static boolean[][] fill(boolean contents, int width, int height) Creates a 2D array of the given width and height, filled with entirely with the value contents. You may want to usefill(boolean[][], boolean)
to modify an existing 2D array instead.- Parameters:
contents
- the value to fill the array withwidth
- the desired widthheight
- the desired height- Returns:
- a freshly allocated 2D array of the requested dimensions, filled entirely with contents
-
fill
public static void fill(boolean[][] array2d, boolean value) Fillsarray2d
withvalue
. Not to be confused withfill(boolean, int, int)
, which makes a new 2D array.- Parameters:
array2d
- a 2D array that will be modified in-place; no sub-arrays can be nullvalue
- the value to fill all of array2D with
-
fill
public static void fill(char[][] array2d, char value) - Parameters:
array2d
- a 2D array that will be modified in-place; no sub-arrays can be nullvalue
- the value to fill all of array2D with
-
fill
public static void fill(float[][] array2d, float value) Fillsarray2d
withvalue
. Not to be confused withfill(float, int, int)
, which makes a new 2D array.- Parameters:
array2d
- a 2D array that will be modified in-place; no sub-arrays can be nullvalue
- the value to fill all of array2D with
-
fill
public static void fill(double[][] array2d, double value) Fillsarray2d
withvalue
. Not to be confused withfill(double, int, int)
, which makes a new 2D array.- Parameters:
array2d
- a 2D array that will be modified in-place; no sub-arrays can be nullvalue
- the value to fill all of array2D with
-
fill
public static void fill(int[][] array2d, int value) - Parameters:
array2d
- a 2D array that will be modified in-place; no sub-arrays can be nullvalue
- the value to fill all of array2D with
-
fill
public static void fill(long[][] array2d, long value) - Parameters:
array2d
- a 2D array that will be modified in-place; no sub-arrays can be nullvalue
- the value to fill all of array2D with
-
fill
public static void fill(byte[][] array2d, byte value) - Parameters:
array2d
- a 2D array that will be modified in-place; no sub-arrays can be nullvalue
- the value to fill all of array2D with
-
fill
public static <T> void fill(T[][] array2d, T value) Fillsarray2d
with identical references tovalue
(not copies). Note that there is no fill() method that creates a new 2D array of a generic type.- Parameters:
array2d
- a 2D array that will be modified in-place; no sub-arrays can be nullvalue
- the value to fill all of array2D with
-
fill3D
public static void fill3D(boolean[][][] array3d, boolean value) Fillsarray3d
withvalue
. Not to be confused withfill(boolean[][], boolean)
, which fills a 2D array instead of a 3D one, or withfill(boolean, int, int)
, which makes a new 2D array. This is named differently to avoid ambiguity between a 1D array ofboolean[][]
, which this can take, and a 2D array ofboolean[]
, which could be given tofill(Object[][], Object)
, but could also be given to this.- Parameters:
array3d
- a 3D array that will be modified in-place; no sub-arrays can be nullvalue
- the value to fill all of array3d with
-
fill3D
public static void fill3D(char[][][] array3d, char value) Fillsarray3d
withvalue
. Not to be confused withfill(char[][], char)
, which fills a 2D array instead of a 3D one, or withfill(char, int, int)
, which makes a new 2D array. This is named differently to avoid ambiguity between a 1D array ofchar[][]
, which this can take, and a 2D array ofchar[]
, which could be given tofill(Object[][], Object)
, but could also be given to this.- Parameters:
array3d
- a 3D array that will be modified in-place; no sub-arrays can be nullvalue
- the value to fill all of array3d with
-
fill3D
public static void fill3D(float[][][] array3d, float value) Fillsarray3d
withvalue
. Not to be confused withfill(float[][], float)
, which fills a 2D array instead of a 3D one, or withfill(float, int, int)
, which makes a new 2D array. This is named differently to avoid ambiguity between a 1D array offloat[][]
, which this can take, and a 2D array offloat[]
, which could be given tofill(Object[][], Object)
, but could also be given to this.- Parameters:
array3d
- a 3D array that will be modified in-place; no sub-arrays can be nullvalue
- the value to fill all of array3d with
-
fill3D
public static void fill3D(double[][][] array3d, double value) Fillsarray3d
withvalue
. Not to be confused withfill(double[][], double)
, which fills a 2D array instead of a 3D one, or withfill(double, int, int)
, which makes a new 2D array. This is named differently to avoid ambiguity between a 1D array ofdouble[][]
, which this can take, and a 2D array ofdouble[]
, which could be given tofill(Object[][], Object)
, but could also be given to this.- Parameters:
array3d
- a 3D array that will be modified in-place; no sub-arrays can be nullvalue
- the value to fill all of array3d with
-
fill3D
public static void fill3D(int[][][] array3d, int value) Fillsarray3d
withvalue
. Not to be confused withfill(int[][], int)
, which fills a 2D array instead of a 3D one, or withfill(int, int, int)
, which makes a new 2D array. This is named differently to avoid ambiguity between a 1D array ofint[][]
, which this can take, and a 2D array ofint[]
, which could be given tofill(Object[][], Object)
, but could also be given to this.- Parameters:
array3d
- a 3D array that will be modified in-place; no sub-arrays can be nullvalue
- the value to fill all of array3d with
-
fill3D
public static void fill3D(long[][][] array3d, long value) Fillsarray3d
withvalue
. Not to be confused withfill(long[][], long)
, which fills a 2D array instead of a 3D one, or withfill(long, int, int)
, which makes a new 2D array. This is named differently to avoid ambiguity between a 1D array oflong[][]
, which this can take, and a 2D array oflong[]
, which could be given tofill(Object[][], Object)
, but could also be given to this.- Parameters:
array3d
- a 3D array that will be modified in-place; no sub-arrays can be nullvalue
- the value to fill all of array3d with
-
fill3D
public static void fill3D(byte[][][] array3d, byte value) Fillsarray3d
withvalue
. Not to be confused withfill(byte[][], byte)
, which fills a 2D array instead of a 3D one, or withfill(byte, int, int)
, which makes a new 2D array. This is named differently to avoid ambiguity between a 1D array ofbyte[][]
, which this can take, and a 2D array ofbyte[]
, which could be given tofill(Object[][], Object)
, but could also be given to this.- Parameters:
array3d
- a 3D array that will be modified in-place; no sub-arrays can be nullvalue
- the value to fill all of array3d with
-
fill3D
public static <T> void fill3D(T[][][] array3d, T value) Fillsarray3d
with identical references tovalue
(not copies). Not to be confused withfill(Object[][], Object)
, which fills a 2D array instead of a 3D one. This is named differently to avoid ambiguity between a 1D array ofT[][]
, which this can take, and a 2D array ofT[]
, which could be given tofill(Object[][], Object)
, but could also be given to this.- Parameters:
array3d
- a 3D array that will be modified in-place; no sub-arrays can be nullvalue
- the value to fill all of array3d with
-
fill
public static void fill(boolean[][] array2d, boolean value, int startX, int startY, int endX, int endY) Fills a sub-section ofarray2d
withvalue
, with the section defined by start/end x/y. Not to be confused withfill(boolean, int, int)
, which makes a new 2D array.- Parameters:
array2d
- a 2D array that will be modified in-placevalue
- the value to fill all of array2D withstartX
- the first x position to fill (inclusive)startY
- the first y position to fill (inclusive)endX
- the last x position to fill (inclusive)endY
- the last y position to fill (inclusive)
-
fill
public static void fill(char[][] array2d, char value, int startX, int startY, int endX, int endY) Fills a sub-section ofarray2d
withvalue
, with the section defined by start/end x/y. Not to be confused withfill(char, int, int)
, which makes a new 2D array.- Parameters:
array2d
- a 2D array that will be modified in-placevalue
- the value to fill all of array2D withstartX
- the first x position to fill (inclusive)startY
- the first y position to fill (inclusive)endX
- the last x position to fill (inclusive)endY
- the last y position to fill (inclusive)
-
fill
public static void fill(float[][] array2d, float value, int startX, int startY, int endX, int endY) Fills a sub-section ofarray2d
withvalue
, with the section defined by start/end x/y. Not to be confused withfill(float, int, int)
, which makes a new 2D array.- Parameters:
array2d
- a 2D array that will be modified in-placevalue
- the value to fill all of array2D withstartX
- the first x position to fill (inclusive)startY
- the first y position to fill (inclusive)endX
- the last x position to fill (inclusive)endY
- the last y position to fill (inclusive)
-
fill
public static void fill(double[][] array2d, double value, int startX, int startY, int endX, int endY) Fills a sub-section ofarray2d
withvalue
, with the section defined by start/end x/y. Not to be confused withfill(double, int, int)
, which makes a new 2D array.- Parameters:
array2d
- a 2D array that will be modified in-placevalue
- the value to fill all of array2D withstartX
- the first x position to fill (inclusive)startY
- the first y position to fill (inclusive)endX
- the last x position to fill (inclusive)endY
- the last y position to fill (inclusive)
-
fill
public static void fill(int[][] array2d, int value, int startX, int startY, int endX, int endY) Fills a sub-section ofarray2d
withvalue
, with the section defined by start/end x/y. Not to be confused withfill(int, int, int)
, which makes a new 2D array.- Parameters:
array2d
- a 2D array that will be modified in-placevalue
- the value to fill all of array2D withstartX
- the first x position to fill (inclusive)startY
- the first y position to fill (inclusive)endX
- the last x position to fill (inclusive)endY
- the last y position to fill (inclusive)
-
fill
public static void fill(long[][] array2d, long value, int startX, int startY, int endX, int endY) Fills a sub-section ofarray2d
withvalue
, with the section defined by start/end x/y. Not to be confused withfill(long, int, int)
, which makes a new 2D array.- Parameters:
array2d
- a 2D array that will be modified in-placevalue
- the value to fill all of array2D withstartX
- the first x position to fill (inclusive)startY
- the first y position to fill (inclusive)endX
- the last x position to fill (inclusive)endY
- the last y position to fill (inclusive)
-
fill
public static <T> void fill(T[][] array2d, T value, int startX, int startY, int endX, int endY) Fills a sub-section ofarray2d
with identical references tovalue
(not copies), with the section defined by start/end x/y.- Parameters:
array2d
- a 2D array that will be modified in-placevalue
- the value to fill all of array2D withstartX
- the first x position to fill (inclusive)startY
- the first y position to fill (inclusive)endX
- the last x position to fill (inclusive)endY
- the last y position to fill (inclusive)
-
reverse
public static long[] reverse(long[] data) Reverses the array given as a parameter, in-place, and returns the modified original.- Parameters:
data
- an array that will be reversed in-place- Returns:
- the array passed in, after reversal
-
reverse
public static boolean[] reverse(boolean[] data) Reverses the array given as a parameter, in-place, and returns the modified original.- Parameters:
data
- an array that will be reversed in-place- Returns:
- the array passed in, after reversal
-
reverse
public static char[] reverse(char[] data) Reverses the array given as a parameter, in-place, and returns the modified original.- Parameters:
data
- an array that will be reversed in-place- Returns:
- the array passed in, after reversal
-
reverse
public static float[] reverse(float[] data) Reverses the array given as a parameter, in-place, and returns the modified original.- Parameters:
data
- an array that will be reversed in-place- Returns:
- the array passed in, after reversal
-
reverse
public static double[] reverse(double[] data) Reverses the array given as a parameter, in-place, and returns the modified original.- Parameters:
data
- an array that will be reversed in-place- Returns:
- the array passed in, after reversal
-
reverse
public static int[] reverse(int[] data) Reverses the array given as a parameter, in-place, and returns the modified original.- Parameters:
data
- an array that will be reversed in-place- Returns:
- the array passed in, after reversal
-
reverse
public static byte[] reverse(byte[] data) Reverses the array given as a parameter, in-place, and returns the modified original.- Parameters:
data
- an array that will be reversed in-place- Returns:
- the array passed in, after reversal
-
reverse
public static <T> T[] reverse(T[] data) Reverses the array given as a parameter, in-place, and returns the modified original.- Parameters:
data
- an array that will be reversed in-place- Returns:
- the array passed in, after reversal
-