Class ArrayTools

java.lang.Object
com.github.tommyettinger.digital.ArrayTools

public final 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, float, double, and boolean). Has a few methods for creating ranges of ints or chars easily as 1D arrays.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static Random
    An unseeded Random instance that is used by shuffle(int[]) and related overloads when given no Random argument or a null one.
  • Method Summary

    Modifier and Type
    Method
    Description
    static char[]
    charSpan(char[] buffer)
    Stupidly simple convenience method that produces a char range from u0000 to uFFFF, limited to buffer.length - 1.
    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 char[]
    charSpan(int end)
    Stupidly simple convenience method that produces a char range from u0000 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)
    Fills array2d with value.
    static void
    fill(boolean[][] array2d, boolean value, int startX, int startY, int endX, int endY)
    Fills a sub-section of array2d with value, 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)
    Fills array2d with value.
    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)
    Fills array2d with value.
    static void
    fill(char[][] array2d, char value, int startX, int startY, int endX, int endY)
    Fills a sub-section of array2d with value, 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)
    Fills array2d with value.
    static void
    fill(double[][] array2d, double value, int startX, int startY, int endX, int endY)
    Fills a sub-section of array2d with value, 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)
    Fills array2d with value.
    static void
    fill(float[][] array2d, float value, int startX, int startY, int endX, int endY)
    Fills a sub-section of array2d with value, 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)
    Fills array2d with value.
    static void
    fill(int[][] array2d, int value, int startX, int startY, int endX, int endY)
    Fills a sub-section of array2d with value, 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)
    Fills array2d with value.
    static void
    fill(long[][] array2d, long value, int startX, int startY, int endX, int endY)
    Fills a sub-section of array2d with value, 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)
    Fills array2d with identical references to value (not copies).
    static <T> void
    fill(T[][] array2d, T value, int startX, int startY, int endX, int endY)
    Fills a sub-section of array2d with identical references to value (not copies), with the section defined by start/end x/y.
    static void
    fill3D(boolean[][][] array3d, boolean value)
    Fills array3d with value.
    static void
    fill3D(byte[][][] array3d, byte value)
    Fills array3d with value.
    static void
    fill3D(char[][][] array3d, char value)
    Fills array3d with value.
    static void
    fill3D(double[][][] array3d, double value)
    Fills array3d with value.
    static void
    fill3D(float[][][] array3d, float value)
    Fills array3d with value.
    static void
    fill3D(int[][][] array3d, int value)
    Fills array3d with value.
    static void
    fill3D(long[][][] array3d, long value)
    Fills array3d with value.
    static <T> void
    fill3D(T[][][] array3d, T value)
    Fills array3d with identical references to value (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 char[]
    letterSpan(int start, 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 to buffer.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.
    static boolean[]
    shuffle(boolean[] data)
    Shuffles the array given as a parameter, in-place, and returns the modified original.
    static boolean[]
    shuffle(boolean[] data, Random rand)
    Shuffles the array given as a parameter, in-place, and returns the modified original.
    static boolean[]
    shuffle(boolean[] data, Random rand, int offset, int length)
    Shuffles a section of the array given as a parameter, in-place, and returns the modified original array.
    static byte[]
    shuffle(byte[] data)
    Shuffles the array given as a parameter, in-place, and returns the modified original.
    static byte[]
    shuffle(byte[] data, Random rand)
    Shuffles the array given as a parameter, in-place, and returns the modified original.
    static byte[]
    shuffle(byte[] data, Random rand, int offset, int length)
    Shuffles a section of the array given as a parameter, in-place, and returns the modified original array.
    static char[]
    shuffle(char[] data)
    Shuffles the array given as a parameter, in-place, and returns the modified original.
    static char[]
    shuffle(char[] data, Random rand)
    Shuffles the array given as a parameter, in-place, and returns the modified original.
    static char[]
    shuffle(char[] data, Random rand, int offset, int length)
    Shuffles a section of the array given as a parameter, in-place, and returns the modified original array.
    static double[]
    shuffle(double[] data)
    Shuffles the array given as a parameter, in-place, and returns the modified original.
    static double[]
    shuffle(double[] data, Random rand)
    Shuffles the array given as a parameter, in-place, and returns the modified original.
    static double[]
    shuffle(double[] data, Random rand, int offset, int length)
    Shuffles a section of the array given as a parameter, in-place, and returns the modified original array.
    static float[]
    shuffle(float[] data)
    Shuffles the array given as a parameter, in-place, and returns the modified original.
    static float[]
    shuffle(float[] data, Random rand)
    Shuffles the array given as a parameter, in-place, and returns the modified original.
    static float[]
    shuffle(float[] data, Random rand, int offset, int length)
    Shuffles a section of the array given as a parameter, in-place, and returns the modified original array.
    static int[]
    shuffle(int[] data)
    Shuffles the array given as a parameter, in-place, and returns the modified original.
    static int[]
    shuffle(int[] data, Random rand)
    Shuffles the array given as a parameter, in-place, and returns the modified original.
    static int[]
    shuffle(int[] data, Random rand, int offset, int length)
    Shuffles a section of the array given as a parameter, in-place, and returns the modified original array.
    static long[]
    shuffle(long[] data)
    Shuffles the array given as a parameter, in-place, and returns the modified original.
    static long[]
    shuffle(long[] data, Random rand)
    Shuffles the array given as a parameter, in-place, and returns the modified original.
    static long[]
    shuffle(long[] data, Random rand, int offset, int length)
    Shuffles a section of the array given as a parameter, in-place, and returns the modified original array.
    static short[]
    shuffle(short[] data)
    Shuffles the array given as a parameter, in-place, and returns the modified original.
    static short[]
    shuffle(short[] data, Random rand)
    Shuffles the array given as a parameter, in-place, and returns the modified original.
    static short[]
    shuffle(short[] data, Random rand, int offset, int length)
    Shuffles a section of the array given as a parameter, in-place, and returns the modified original array.
    static <T> T[]
    shuffle(T[] data)
    Shuffles the array given as a parameter, in-place, and returns the modified original.
    static <T> T[]
    shuffle(T[] data, Random rand)
    Shuffles the array given as a parameter, in-place, and returns the modified original.
    static <T> T[]
    shuffle(T[] data, Random rand, int offset, int length)
    Shuffles a section of the array given as a parameter, in-place, and returns the modified original array.
    static boolean[][]
    shuffle2D(boolean[][] data)
    Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
    static boolean[][]
    shuffle2D(boolean[][] data, Random rand)
    Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
    static byte[][]
    shuffle2D(byte[][] data)
    Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
    static byte[][]
    shuffle2D(byte[][] data, Random rand)
    Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
    static char[][]
    shuffle2D(char[][] data)
    Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
    static char[][]
    shuffle2D(char[][] data, Random rand)
    Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
    static double[][]
    shuffle2D(double[][] data)
    Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
    static double[][]
    shuffle2D(double[][] data, Random rand)
    Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
    static float[][]
    shuffle2D(float[][] data)
    Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
    static float[][]
    shuffle2D(float[][] data, Random rand)
    Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
    static int[][]
    shuffle2D(int[][] data)
    Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
    static int[][]
    shuffle2D(int[][] data, Random rand)
    Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
    static long[][]
    shuffle2D(long[][] data)
    Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
    static long[][]
    shuffle2D(long[][] data, Random rand)
    Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
    static short[][]
    shuffle2D(short[][] data)
    Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
    static short[][]
    shuffle2D(short[][] data, Random rand)
    Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
    static <T> T[][]
    shuffle2D(T[][] data)
    Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
    static <T> T[][]
    shuffle2D(T[][] data, Random rand)
    Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • RANDOM

      public static Random RANDOM
      An unseeded Random instance that is used by shuffle(int[]) and related overloads when given no Random argument or a null one. This cannot be relied upon to have a given state, even if you set the seed; if you need a deterministic state, use your own seeded Random object and pass it to shuffle(). You could assign null to this, but it's a very bad idea and will probably result in a crash; a better idea is to assign a subclass of Random with a larger state size, such as a RandomXS128 from libGDX or any generator from juniper.
  • 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 to buffer.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 range
      end - 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
    • charSpan

      public static char[] charSpan(char[] buffer)
      Stupidly simple convenience method that produces a char range from u0000 to uFFFF, limited to buffer.length - 1.
      Parameters:
      buffer - a char array that will be modified in-place; if null this returns null
      Returns:
      the range of chars as a char array
    • charSpan

      public static char[] charSpan(int end)
      Stupidly simple convenience method that produces a char range from u0000 to end, including end, as a char array.
      Parameters:
      end - the inclusive upper bound on the range; typically a char, but may be larger than 0xFFFF to repeat
      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 use charSpan(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
    • letterSpan

      public static char[] letterSpan(int start, 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 use charSpan(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:
      start - the index of the first letter in the source of 256 chars to use
      charCount - the number of letters to return in an array; the maximum this can 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 target
      target - a 2D char array that will be modified by receiving as much of source as it can hold
      x - the x position in target to receive the items from the first cell in source
      y - 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 target
      target - a 2D double array that will be modified by receiving as much of source as it can hold
      x - the x position in target to receive the items from the first cell in source
      y - 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 target
      target - a 2D float array that will be modified by receiving as much of source as it can hold
      x - the x position in target to receive the items from the first cell in source
      y - 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 target
      target - a 2D int array that will be modified by receiving as much of source as it can hold
      x - the x position in target to receive the items from the first cell in source
      y - 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 target
      target - a 2D long array that will be modified by receiving as much of source as it can hold
      x - the x position in target to receive the items from the first cell in source
      y - 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 target
      target - a 2D boolean array that will be modified by receiving as much of source as it can hold
      x - the x position in target to receive the items from the first cell in source
      y - 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 as target.
      Parameters:
      source - a 2D generic array that will be copied and inserted into target
      target - a 2D generic array that will be modified by receiving as much of source as it can hold
      x - the x position in target to receive the items from the first cell in source
      y - 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 like insert(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 target
      target - 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 like insert(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 target
      target - 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 like insert(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 target
      target - 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 like insert(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 target
      target - 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 like insert(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 target
      target - 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 like insert(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 target
      target - 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 like insert(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 as target.
      Parameters:
      source - a 2D generic array that will be copied and inserted into target
      target - 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 use fill(char[][], char) to modify an existing 2D array instead.
      Parameters:
      contents - the value to fill the array with
      width - the desired width
      height - 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 use fill(float[][], float) to modify an existing 2D array instead.
      Parameters:
      contents - the value to fill the array with
      width - the desired width
      height - 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 use fill(double[][], double) to modify an existing 2D array instead.
      Parameters:
      contents - the value to fill the array with
      width - the desired width
      height - 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 use fill(int[][], int) to modify an existing 2D array instead.
      Parameters:
      contents - the value to fill the array with
      width - the desired width
      height - 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 use fill(long[][], long) to modify an existing 2D array instead.
      Parameters:
      contents - the value to fill the array with
      width - the desired width
      height - 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 use fill(byte[][], byte) to modify an existing 2D array instead.
      Parameters:
      contents - the value to fill the array with
      width - the desired width
      height - 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 use fill(boolean[][], boolean) to modify an existing 2D array instead.
      Parameters:
      contents - the value to fill the array with
      width - the desired width
      height - 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)
      Fills array2d with value. Not to be confused with fill(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 null
      value - the value to fill all of array2D with
    • fill

      public static void fill(char[][] array2d, char value)
      Fills array2d with value. Not to be confused with fill(char, int, int), which makes a new 2D array.
      Parameters:
      array2d - a 2D array that will be modified in-place; no sub-arrays can be null
      value - the value to fill all of array2D with
    • fill

      public static void fill(float[][] array2d, float value)
      Fills array2d with value. Not to be confused with fill(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 null
      value - the value to fill all of array2D with
    • fill

      public static void fill(double[][] array2d, double value)
      Fills array2d with value. Not to be confused with fill(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 null
      value - the value to fill all of array2D with
    • fill

      public static void fill(int[][] array2d, int value)
      Fills array2d with value. Not to be confused with fill(int, int, int), which makes a new 2D array.
      Parameters:
      array2d - a 2D array that will be modified in-place; no sub-arrays can be null
      value - the value to fill all of array2D with
    • fill

      public static void fill(long[][] array2d, long value)
      Fills array2d with value. Not to be confused with fill(long, int, int), which makes a new 2D array.
      Parameters:
      array2d - a 2D array that will be modified in-place; no sub-arrays can be null
      value - the value to fill all of array2D with
    • fill

      public static void fill(byte[][] array2d, byte value)
      Fills array2d with value. Not to be confused with fill(byte, int, int), which makes a new 2D array.
      Parameters:
      array2d - a 2D array that will be modified in-place; no sub-arrays can be null
      value - the value to fill all of array2D with
    • fill

      public static <T> void fill(T[][] array2d, T value)
      Fills array2d with identical references to value (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 null
      value - the value to fill all of array2D with
    • fill3D

      public static void fill3D(boolean[][][] array3d, boolean value)
      Fills array3d with value. Not to be confused with fill(boolean[][], boolean), which fills a 2D array instead of a 3D one, or with fill(boolean, int, int), which makes a new 2D array. This is named differently to avoid ambiguity between a 1D array of boolean[][], which this can take, and a 2D array of boolean[], which could be given to fill(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 null
      value - the value to fill all of array3d with
    • fill3D

      public static void fill3D(char[][][] array3d, char value)
      Fills array3d with value. Not to be confused with fill(char[][], char), which fills a 2D array instead of a 3D one, or with fill(char, int, int), which makes a new 2D array. This is named differently to avoid ambiguity between a 1D array of char[][], which this can take, and a 2D array of char[], which could be given to fill(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 null
      value - the value to fill all of array3d with
    • fill3D

      public static void fill3D(float[][][] array3d, float value)
      Fills array3d with value. Not to be confused with fill(float[][], float), which fills a 2D array instead of a 3D one, or with fill(float, int, int), which makes a new 2D array. This is named differently to avoid ambiguity between a 1D array of float[][], which this can take, and a 2D array of float[], which could be given to fill(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 null
      value - the value to fill all of array3d with
    • fill3D

      public static void fill3D(double[][][] array3d, double value)
      Fills array3d with value. Not to be confused with fill(double[][], double), which fills a 2D array instead of a 3D one, or with fill(double, int, int), which makes a new 2D array. This is named differently to avoid ambiguity between a 1D array of double[][], which this can take, and a 2D array of double[], which could be given to fill(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 null
      value - the value to fill all of array3d with
    • fill3D

      public static void fill3D(int[][][] array3d, int value)
      Fills array3d with value. Not to be confused with fill(int[][], int), which fills a 2D array instead of a 3D one, or with fill(int, int, int), which makes a new 2D array. This is named differently to avoid ambiguity between a 1D array of int[][], which this can take, and a 2D array of int[], which could be given to fill(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 null
      value - the value to fill all of array3d with
    • fill3D

      public static void fill3D(long[][][] array3d, long value)
      Fills array3d with value. Not to be confused with fill(long[][], long), which fills a 2D array instead of a 3D one, or with fill(long, int, int), which makes a new 2D array. This is named differently to avoid ambiguity between a 1D array of long[][], which this can take, and a 2D array of long[], which could be given to fill(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 null
      value - the value to fill all of array3d with
    • fill3D

      public static void fill3D(byte[][][] array3d, byte value)
      Fills array3d with value. Not to be confused with fill(byte[][], byte), which fills a 2D array instead of a 3D one, or with fill(byte, int, int), which makes a new 2D array. This is named differently to avoid ambiguity between a 1D array of byte[][], which this can take, and a 2D array of byte[], which could be given to fill(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 null
      value - the value to fill all of array3d with
    • fill3D

      public static <T> void fill3D(T[][][] array3d, T value)
      Fills array3d with identical references to value (not copies). Not to be confused with fill(Object[][], Object), which fills a 2D array instead of a 3D one. This is named differently to avoid ambiguity between a 1D array of T[][], which this can take, and a 2D array of T[], which could be given to fill(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 null
      value - 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 of array2d with value, with the section defined by start/end x/y. Not to be confused with fill(boolean, int, int), which makes a new 2D array.
      Parameters:
      array2d - a 2D array that will be modified in-place
      value - the value to fill all of array2D with
      startX - 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 of array2d with value, with the section defined by start/end x/y. Not to be confused with fill(char, int, int), which makes a new 2D array.
      Parameters:
      array2d - a 2D array that will be modified in-place
      value - the value to fill all of array2D with
      startX - 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 of array2d with value, with the section defined by start/end x/y. Not to be confused with fill(float, int, int), which makes a new 2D array.
      Parameters:
      array2d - a 2D array that will be modified in-place
      value - the value to fill all of array2D with
      startX - 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 of array2d with value, with the section defined by start/end x/y. Not to be confused with fill(double, int, int), which makes a new 2D array.
      Parameters:
      array2d - a 2D array that will be modified in-place
      value - the value to fill all of array2D with
      startX - 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 of array2d with value, with the section defined by start/end x/y. Not to be confused with fill(int, int, int), which makes a new 2D array.
      Parameters:
      array2d - a 2D array that will be modified in-place
      value - the value to fill all of array2D with
      startX - 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 of array2d with value, with the section defined by start/end x/y. Not to be confused with fill(long, int, int), which makes a new 2D array.
      Parameters:
      array2d - a 2D array that will be modified in-place
      value - the value to fill all of array2D with
      startX - 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 of array2d with identical references to value (not copies), with the section defined by start/end x/y.
      Parameters:
      array2d - a 2D array that will be modified in-place
      value - the value to fill all of array2D with
      startX - 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
    • shuffle

      public static long[] shuffle(long[] data)
      Shuffles the array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      Returns:
      the array passed in, after shuffling
    • shuffle

      public static long[] shuffle(long[] data, Random rand)
      Shuffles the array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      rand - a possibly-seeded random number generator; can be null to use the unseeded RANDOM
      Returns:
      the array passed in, after shuffling
    • shuffle

      public static long[] shuffle(long[] data, Random rand, int offset, int length)
      Shuffles a section of the array given as a parameter, in-place, and returns the modified original array. This can be useful for shuffling collections such as libGDX's LongArray.
      Parameters:
      data - an array that will be shuffled in-place
      rand - a possibly-seeded random number generator; can be null to use the unseeded RANDOM
      offset - the index of the first element of the array that can be shuffled
      length - the length of the section to shuffle
      Returns:
      the array passed in, after shuffling
    • shuffle

      public static boolean[] shuffle(boolean[] data)
      Shuffles the array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      Returns:
      the array passed in, after shuffling
    • shuffle

      public static boolean[] shuffle(boolean[] data, Random rand)
      Shuffles the array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      rand - a possibly-seeded random number generator; can be null to use the unseeded RANDOM
      Returns:
      the array passed in, after shuffling
    • shuffle

      public static boolean[] shuffle(boolean[] data, Random rand, int offset, int length)
      Shuffles a section of the array given as a parameter, in-place, and returns the modified original array. This can be useful for shuffling collections such as libGDX's BooleanArray.
      Parameters:
      data - an array that will be shuffled in-place
      rand - a possibly-seeded random number generator; can be null to use the unseeded RANDOM
      offset - the index of the first element of the array that can be shuffled
      length - the length of the section to shuffle
      Returns:
      the array passed in, after shuffling
    • shuffle

      public static char[] shuffle(char[] data)
      Shuffles the array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      Returns:
      the array passed in, after shuffling
    • shuffle

      public static char[] shuffle(char[] data, Random rand)
      Shuffles the array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      rand - a possibly-seeded random number generator; can be null to use the unseeded RANDOM
      Returns:
      the array passed in, after shuffling
    • shuffle

      public static char[] shuffle(char[] data, Random rand, int offset, int length)
      Shuffles a section of the array given as a parameter, in-place, and returns the modified original array. This can be useful for shuffling collections such as libGDX's CharArray.
      Parameters:
      data - an array that will be shuffled in-place
      rand - a possibly-seeded random number generator; can be null to use the unseeded RANDOM
      offset - the index of the first element of the array that can be shuffled
      length - the length of the section to shuffle
      Returns:
      the array passed in, after shuffling
    • shuffle

      public static float[] shuffle(float[] data)
      Shuffles the array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      Returns:
      the array passed in, after shuffling
    • shuffle

      public static float[] shuffle(float[] data, Random rand)
      Shuffles the array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      rand - a possibly-seeded random number generator; can be null to use the unseeded RANDOM
      Returns:
      the array passed in, after shuffling
    • shuffle

      public static float[] shuffle(float[] data, Random rand, int offset, int length)
      Shuffles a section of the array given as a parameter, in-place, and returns the modified original array. This can be useful for shuffling collections such as libGDX's FloatArray.
      Parameters:
      data - an array that will be shuffled in-place
      rand - a possibly-seeded random number generator; can be null to use the unseeded RANDOM
      offset - the index of the first element of the array that can be shuffled
      length - the length of the section to shuffle
      Returns:
      the array passed in, after shuffling
    • shuffle

      public static double[] shuffle(double[] data)
      Shuffles the array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      Returns:
      the array passed in, after shuffling
    • shuffle

      public static double[] shuffle(double[] data, Random rand)
      Shuffles the array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      rand - a possibly-seeded random number generator; can be null to use the unseeded RANDOM
      Returns:
      the array passed in, after shuffling
    • shuffle

      public static double[] shuffle(double[] data, Random rand, int offset, int length)
      Shuffles a section of the array given as a parameter, in-place, and returns the modified original array.
      Parameters:
      data - an array that will be shuffled in-place
      rand - a possibly-seeded random number generator; can be null to use the unseeded RANDOM
      offset - the index of the first element of the array that can be shuffled
      length - the length of the section to shuffle
      Returns:
      the array passed in, after shuffling
    • shuffle

      public static int[] shuffle(int[] data)
      Shuffles the array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      Returns:
      the array passed in, after shuffling
    • shuffle

      public static int[] shuffle(int[] data, Random rand)
      Shuffles the array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      rand - a possibly-seeded random number generator; can be null to use the unseeded RANDOM
      Returns:
      the array passed in, after shuffling
    • shuffle

      public static int[] shuffle(int[] data, Random rand, int offset, int length)
      Shuffles a section of the array given as a parameter, in-place, and returns the modified original array. This can be useful for shuffling collections such as libGDX's IntArray.
      Parameters:
      data - an array that will be shuffled in-place
      rand - a possibly-seeded random number generator; can be null to use the unseeded RANDOM
      offset - the index of the first element of the array that can be shuffled
      length - the length of the section to shuffle
      Returns:
      the array passed in, after shuffling
    • shuffle

      public static short[] shuffle(short[] data)
      Shuffles the array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      Returns:
      the array passed in, after shuffling
    • shuffle

      public static short[] shuffle(short[] data, Random rand)
      Shuffles the array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      rand - a possibly-seeded random number generator; can be null to use the unseeded RANDOM
      Returns:
      the array passed in, after shuffling
    • shuffle

      public static short[] shuffle(short[] data, Random rand, int offset, int length)
      Shuffles a section of the array given as a parameter, in-place, and returns the modified original array. This can be useful for shuffling collections such as libGDX's ShortArray.
      Parameters:
      data - an array that will be shuffled in-place
      rand - a possibly-seeded random number generator; can be null to use the unseeded RANDOM
      offset - the index of the first element of the array that can be shuffled
      length - the length of the section to shuffle
      Returns:
      the array passed in, after shuffling
    • shuffle

      public static byte[] shuffle(byte[] data)
      Shuffles the array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      Returns:
      the array passed in, after shuffling
    • shuffle

      public static byte[] shuffle(byte[] data, Random rand)
      Shuffles the array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      rand - a possibly-seeded random number generator; can be null to use the unseeded RANDOM
      Returns:
      the array passed in, after shuffling
    • shuffle

      public static byte[] shuffle(byte[] data, Random rand, int offset, int length)
      Shuffles a section of the array given as a parameter, in-place, and returns the modified original array. This can be useful for shuffling collections such as libGDX's ByteArray.
      Parameters:
      data - an array that will be shuffled in-place
      rand - a possibly-seeded random number generator; can be null to use the unseeded RANDOM
      offset - the index of the first element of the array that can be shuffled
      length - the length of the section to shuffle
      Returns:
      the array passed in, after shuffling
    • shuffle

      public static <T> T[] shuffle(T[] data)
      Shuffles the array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      Returns:
      the array passed in, after shuffling
    • shuffle

      public static <T> T[] shuffle(T[] data, Random rand)
      Shuffles the array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      rand - a possibly-seeded random number generator; can be null to use the unseeded RANDOM
      Returns:
      the array passed in, after shuffling
    • shuffle

      public static <T> T[] shuffle(T[] data, Random rand, int offset, int length)
      Shuffles a section of the array given as a parameter, in-place, and returns the modified original array. This can be useful for shuffling collections such as libGDX's Array types.
      Parameters:
      data - an array that will be shuffled in-place
      rand - a possibly-seeded random number generator; can be null to use the unseeded RANDOM
      offset - the index of the first element of the array that can be shuffled
      length - the length of the section to shuffle
      Returns:
      the array passed in, after shuffling
    • shuffle2D

      public static boolean[][] shuffle2D(boolean[][] data)
      Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      Returns:
      the array passed in, after shuffling
    • shuffle2D

      public static boolean[][] shuffle2D(boolean[][] data, Random rand)
      Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      rand - a possibly-seeded random number generator; can be null to use the unseeded RANDOM
      Returns:
      the array passed in, after shuffling
    • shuffle2D

      public static char[][] shuffle2D(char[][] data)
      Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      Returns:
      the array passed in, after shuffling
    • shuffle2D

      public static char[][] shuffle2D(char[][] data, Random rand)
      Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      rand - a possibly-seeded random number generator; can be null to use the unseeded RANDOM
      Returns:
      the array passed in, after shuffling
    • shuffle2D

      public static long[][] shuffle2D(long[][] data)
      Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      Returns:
      the array passed in, after shuffling
    • shuffle2D

      public static long[][] shuffle2D(long[][] data, Random rand)
      Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      rand - a possibly-seeded random number generator; can be null to use the unseeded RANDOM
      Returns:
      the array passed in, after shuffling
    • shuffle2D

      public static int[][] shuffle2D(int[][] data)
      Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      Returns:
      the array passed in, after shuffling
    • shuffle2D

      public static int[][] shuffle2D(int[][] data, Random rand)
      Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      rand - a possibly-seeded random number generator; can be null to use the unseeded RANDOM
      Returns:
      the array passed in, after shuffling
    • shuffle2D

      public static byte[][] shuffle2D(byte[][] data)
      Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      Returns:
      the array passed in, after shuffling
    • shuffle2D

      public static byte[][] shuffle2D(byte[][] data, Random rand)
      Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      rand - a possibly-seeded random number generator; can be null to use the unseeded RANDOM
      Returns:
      the array passed in, after shuffling
    • shuffle2D

      public static short[][] shuffle2D(short[][] data)
      Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      Returns:
      the array passed in, after shuffling
    • shuffle2D

      public static short[][] shuffle2D(short[][] data, Random rand)
      Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      rand - a possibly-seeded random number generator; can be null to use the unseeded RANDOM
      Returns:
      the array passed in, after shuffling
    • shuffle2D

      public static float[][] shuffle2D(float[][] data)
      Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      Returns:
      the array passed in, after shuffling
    • shuffle2D

      public static float[][] shuffle2D(float[][] data, Random rand)
      Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      rand - a possibly-seeded random number generator; can be null to use the unseeded RANDOM
      Returns:
      the array passed in, after shuffling
    • shuffle2D

      public static double[][] shuffle2D(double[][] data)
      Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      Returns:
      the array passed in, after shuffling
    • shuffle2D

      public static double[][] shuffle2D(double[][] data, Random rand)
      Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      rand - a possibly-seeded random number generator; can be null to use the unseeded RANDOM
      Returns:
      the array passed in, after shuffling
    • shuffle2D

      public static <T> T[][] shuffle2D(T[][] data)
      Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      Returns:
      the array passed in, after shuffling
    • shuffle2D

      public static <T> T[][] shuffle2D(T[][] data, Random rand)
      Shuffles the rectangular 2D array given as a parameter, in-place, and returns the modified original.
      Parameters:
      data - an array that will be shuffled in-place
      rand - a possibly-seeded random number generator; can be null to use the unseeded RANDOM
      Returns:
      the array passed in, after shuffling