Package squidpony
Class ArrayTools
java.lang.Object
squidpony.ArrayTools
public class ArrayTools extends Object
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, double, and boolean). Has a few mehods for creating ranges of ints
or chars easily as 1D arrays. Also contains certain methods for working with orderings, which can be naturally used
with
OrderedMap
, OrderedSet
, K2
,
and similar ordered collections plus ArrayList using reorder(ArrayList, int...)
in this class.
Created by Tommy Ettinger on 11/17/2016.-
Constructor Summary
Constructors Constructor Description ArrayTools()
-
Method Summary
Modifier and Type Method Description 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.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 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[][][] array3d, double value)
Fillsarray3d
withvalue
.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 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 int[]
invertOrdering(int[] ordering)
Given an ordering such as one produced byRNG.randomOrdering(int, int[])
, this finds its inverse, able to reverse the reordering and vice versa.static int[]
invertOrdering(int[] ordering, int[] dest)
Given an ordering such as one produced byRNG.randomOrdering(int, int[])
, this finds its inverse, able to reverse the reordering and vice versa.static char
letterAt(int index)
Gets the nth letter from the set that SquidLib is likely to support; 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 SquidLib's default text display assets, at least).static void
randomFill(char[][] array2d, char[] values, long seed)
Randomly fills all ofarray2d
with random values generated fromseed
, choosing chars to place in the given 2D array by selecting them at random from the given 1D char arrayvalues
.static void
randomFill(char[][] array2d, CharSequence values, long seed)
Randomly fills all ofarray2d
with random values generated fromseed
, choosing chars to place in the given 2D array by selecting them at random from the given 1D char arrayvalues
.static void
randomFill(double[][] array2d, double bound, long seed)
Randomly fills all ofarray2d
with random values generated fromseed
, limiting results to between 0 andbound
, exclusive.static void
randomFill(double[][] array2d, long seed)
Randomly fills all ofarray2d
with random values generated fromseed
; can fill an element with any double between 0.0 inclusive and 1.0 exclusive.static void
randomFill(float[][] array2d, float bound, long seed)
Randomly fills all ofarray2d
with random values generated fromseed
, limiting results to between 0 andbound
, exclusive.static void
randomFill(float[][] array2d, long seed)
Randomly fills all ofarray2d
with random values generated fromseed
; can fill an element with any float between 0.0 inclusive and 1.0 exclusive.static void
randomFill(int[][] array2d, int bound, long seed)
Randomly fills all ofarray2d
with random values generated fromseed
, limiting results to between 0 andbound
, exclusive.static void
randomFill(int[][] array2d, long seed)
Randomly fills all ofarray2d
with random values generated fromseed
; can fill an element with any int, positive or negative.static void
randomFill(long[][] array2d, long seed)
Randomly fills all ofarray2d
with random values generated fromseed
; can fill an element with any long, positive or negative.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 start, int end)
Stupidly simple convenience method that produces a range from start to end, not including end, as an int array.static <T> ArrayList<T>
reorder(ArrayList<T> list, int... ordering)
Rearranges an ArrayList to use the given ordering, returning a copy; random orderings can be produced withRNG.randomOrdering(int)
orRNG.randomOrdering(int, int[])
.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 <T> T[]
reverse(T[] data)
Reverses the array given as a parameter, in-place, and returns the modified original.
-
Constructor Details
-
ArrayTools
public ArrayTools()
-
-
Method Details
-
range
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
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
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
Stupidly simple convenience method that produces a char array containing only letters that can be reasonably displayed (with SquidLib's default text display assets, at least). 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
Gets the nth letter from the set that SquidLib is likely to support; 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 the letters SquidLib usually supports
-
copy
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
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
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
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
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
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
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
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
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
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
-
fill
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
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
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
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
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
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
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-placevalue
- the value to fill all of array2D with
-
fill
- Parameters:
array2d
- a 2D array that will be modified in-placevalue
- the value to fill all of array2D with
-
fill
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-placevalue
- the value to fill all of array2D with
-
fill
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-placevalue
- the value to fill all of array2D with
-
fill
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.- Parameters:
array3d
- a 3D array that will be modified in-placevalue
- the value to fill all of array3d with
-
fill
- Parameters:
array2d
- a 2D array that will be modified in-placevalue
- the value to fill all of array2D with
-
fill
- Parameters:
array2d
- a 2D array that will be modified in-placevalue
- the value to fill all of array2D 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
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
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)
-
randomFill
Randomly fills all ofarray2d
with random values generated fromseed
; can fill an element with any long, positive or negative. Fairly efficient; uses a fast random number generation algorithm that can avoid some unnecessary work in this context, and improves quality by seeding each column differently. Generates(height + 1) * width
random values to fill theheight * width
elements in array2d.- Parameters:
array2d
- a 2D array that will be modified in-placeseed
- the seed for the random values, as a long
-
randomFill
Randomly fills all ofarray2d
with random values generated fromseed
; can fill an element with any int, positive or negative. Fairly efficient; uses a fast random number generation algorithm that can avoid some unnecessary work in this context, and improves quality by seeding each column differently. Generates(height + 1) * width
random values to fill theheight * width
elements in array2d.- Parameters:
array2d
- a 2D array that will be modified in-placeseed
- the seed for the random values, as a long
-
randomFill
Randomly fills all ofarray2d
with random values generated fromseed
, limiting results to between 0 andbound
, exclusive. Fairly efficient; uses a fast random number generation algorithm that can avoid some unnecessary work in this context, and improves quality by seeding each column differently. Generates(height + 1) * width
random values to fill theheight * width
elements in array2d.- Parameters:
array2d
- a 2D array that will be modified in-placebound
- the upper exclusive limit for the ints this can produceseed
- the seed for the random values, as a long
-
randomFill
Randomly fills all ofarray2d
with random values generated fromseed
, choosing chars to place in the given 2D array by selecting them at random from the given 1D char arrayvalues
. Fairly efficient; uses a fast random number generation algorithm that can avoid some unnecessary work in this context, and improves quality by seeding each column differently. Generates(height + 1) * width
random values to fill theheight * width
elements in array2d.- Parameters:
array2d
- a 2D array that will be modified in-placevalues
- a 1D char array containing the possible char values that can be chosen to fill array2dseed
- the seed for the random values, as a long
-
randomFill
Randomly fills all ofarray2d
with random values generated fromseed
, choosing chars to place in the given 2D array by selecting them at random from the given 1D char arrayvalues
. Fairly efficient; uses a fast random number generation algorithm that can avoid some unnecessary work in this context, and improves quality by seeding each column differently. Generates(height + 1) * width
random values to fill theheight * width
elements in array2d.- Parameters:
array2d
- a 2D array that will be modified in-placevalues
- a 1D char array containing the possible char values that can be chosen to fill array2dseed
- the seed for the random values, as a long
-
randomFill
Randomly fills all ofarray2d
with random values generated fromseed
; can fill an element with any float between 0.0 inclusive and 1.0 exclusive. Fairly efficient; uses a fast random number generation algorithm that can avoid some unnecessary work in this context, and improves quality by seeding each column differently. Generates(height + 1) * width
random values to fill theheight * width
elements in array2d.- Parameters:
array2d
- a 2D array that will be modified in-placeseed
- the seed for the random values, as a long
-
randomFill
Randomly fills all ofarray2d
with random values generated fromseed
, limiting results to between 0 andbound
, exclusive. Fairly efficient; uses a fast random number generation algorithm that can avoid some unnecessary work in this context, and improves quality by seeding each column differently. Generates(height + 1) * width
random values to fill theheight * width
elements in array2d.- Parameters:
array2d
- a 2D array that will be modified in-placebound
- the upper exclusive limit for the floats this can produceseed
- the seed for the random values, as a long
-
randomFill
Randomly fills all ofarray2d
with random values generated fromseed
; can fill an element with any double between 0.0 inclusive and 1.0 exclusive. Fairly efficient; uses a fast random number generation algorithm that can avoid some unnecessary work in this context, and improves quality by seeding each column differently. Generates(height + 1) * width
random values to fill theheight * width
elements in array2d.- Parameters:
array2d
- a 2D array that will be modified in-placeseed
- the seed for the random values, as a long
-
randomFill
Randomly fills all ofarray2d
with random values generated fromseed
, limiting results to between 0 andbound
, exclusive. Fairly efficient; uses a fast random number generation algorithm that can avoid some unnecessary work in this context, and improves quality by seeding each column differently. Generates(height + 1) * width
random values to fill theheight * width
elements in array2d.- Parameters:
array2d
- a 2D array that will be modified in-placebound
- the upper exclusive limit for the doubles this can produceseed
- the seed for the random values, as a long
-
reorder
Rearranges an ArrayList to use the given ordering, returning a copy; random orderings can be produced withRNG.randomOrdering(int)
orRNG.randomOrdering(int, int[])
. These orderings will never repeat an earlier element, and the returned ArrayList may be shorter than the original ifordering
isn't as long aslist
. Using a random ordering is like shuffling, but allows you to repeat the shuffle exactly on other collections of the same size. A reordering can also be inverted withinvertOrdering(int[])
orinvertOrdering(int[], int[])
, getting the change that will undo another ordering.- Type Parameters:
T
- any generic type- Parameters:
list
- an ArrayList that you want a reordered version of; will not be modified.ordering
- an ordering, typically produced by one of RNG's randomOrdering methods.- Returns:
- a modified copy of
list
with its ordering changed to matchordering
.
-
invertOrdering
Given an ordering such as one produced byRNG.randomOrdering(int, int[])
, this finds its inverse, able to reverse the reordering and vice versa.- Parameters:
ordering
- the ordering to find the inverse for- Returns:
- the inverse of ordering
-
invertOrdering
Given an ordering such as one produced byRNG.randomOrdering(int, int[])
, this finds its inverse, able to reverse the reordering and vice versa. This overload doesn't allocate a new int array, and instead relies on having an int array of the same size as ordering passed to it as an additional argument.- Parameters:
ordering
- the ordering to find the inverse fordest
- the int array to put the inverse reordering into; should have the same length as ordering- Returns:
- the inverse of ordering; will have the same value as dest
-
reverse
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
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
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
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
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
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
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
-