java.lang.Object
org.cicirello.util.ArrayFiller
Utility class for filling integer arrays with consecutive integers.
- 
Method Summary
Modifier and TypeMethodDescriptionstatic int[]create(int n) Creates an array and fills it with the integers: 0, 1, ....static int[]create(int n, int offset) Creates an array and fills it with the integers: x+0, x+1, ....static int[]createReverse(int n) Creates an array and fills it with the integers: n-1, n-1, ..., 1, 0, where n is the length of the array.static int[]createReverse(int n, int offset) Creates an array and fills it with the integers: x+n-1, x+n-1, ..., x+1, x, where n is the length of the array.static voidfill(int[] array) Fills an existing array with integers: 0, 1, ....static voidfill(int[] array, int offset) Fills an existing array with integers: x+0, x+1, ....static voidfillPartial(int[] array, int k) Fills part of an existing array with integers: 0, 1, ..., (k-1).static voidfillPartial(int[] array, int k, int offset) Fills part of an existing array with integers: x+0, x+1, ....static voidreverse(int[] array) Fills an existing array with integers: n-1, n-2, ..., 1, 0, where n is the length of the arraystatic voidreverse(int[] array, int offset) Fills an existing array with integers: x+n-1, x+n-2, ..., x+1, x, where n is the length of the array 
- 
Method Details
- 
create
public static int[] create(int n) Creates an array and fills it with the integers: 0, 1, ....- Parameters:
 n- The length of the array.- Returns:
 - The newly created array.
 
 - 
create
public static int[] create(int n, int offset) Creates an array and fills it with the integers: x+0, x+1, ....- Parameters:
 n- The length of the array.offset- The amount to offset each integer by, i.e., the value of the first int in the sequence.- Returns:
 - The newly created array.
 
 - 
createReverse
public static int[] createReverse(int n) Creates an array and fills it with the integers: n-1, n-1, ..., 1, 0, where n is the length of the array.- Parameters:
 n- The length of the array.- Returns:
 - The newly created array.
 
 - 
createReverse
public static int[] createReverse(int n, int offset) Creates an array and fills it with the integers: x+n-1, x+n-1, ..., x+1, x, where n is the length of the array.- Parameters:
 n- The length of the array.offset- The amount to offset each integer by, i.e., the value of the last int in the sequence.- Returns:
 - The newly created array.
 
 - 
fill
public static void fill(int[] array) Fills an existing array with integers: 0, 1, ....- Parameters:
 array- The array to fill.
 - 
fill
public static void fill(int[] array, int offset) Fills an existing array with integers: x+0, x+1, ....- Parameters:
 array- The array to fill.offset- The amount to offset each integer by, i.e., the value of the first int in the sequence.
 - 
fillPartial
public static void fillPartial(int[] array, int k) Fills part of an existing array with integers: 0, 1, ..., (k-1).- Parameters:
 array- The array to fill.k- The size of the part of the array to fill.
 - 
fillPartial
public static void fillPartial(int[] array, int k, int offset) Fills part of an existing array with integers: x+0, x+1, ....- Parameters:
 array- The array to fill.k- The size of the part of the array to fill.offset- The amount to offset each integer by, i.e., the value of the first int in the sequence.
 - 
reverse
public static void reverse(int[] array) Fills an existing array with integers: n-1, n-2, ..., 1, 0, where n is the length of the array- Parameters:
 array- The array to fill.
 - 
reverse
public static void reverse(int[] array, int offset) Fills an existing array with integers: x+n-1, x+n-2, ..., x+1, x, where n is the length of the array- Parameters:
 array- The array to fill.offset- The amount to offset each integer by, i.e., the value of the last int in the sequence.
 
 -