Package stdlib
Class ArrayGenerator
java.lang.Object
stdlib.ArrayGenerator
Provides methods to generate arrays of Integer objects,
arrays of doubles in [0.0,1.0), and arrays of characters.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic double[]doublePartiallySortedUnique(int N) Generate a partially sorted array with unique elements.static double[]doublePartiallySortedUnique2(int N) Generate a partially sorted array with unique elements.static double[]doubleRandom(int N, int numValues) Generate an array of length N whose values are chosen uniformly from the range [0,numValues).static double[]doubleRandomUnique(int N) Generate a shuffled array of length N with unique values 0, 1, ...static double[]doubleReverseSortedUnique(int N) Generate an array of length N with values N-1, N-2, ...static double[]Generate an array of doubles from a string.static double[]doubleSortedUnique(int N) Generate an array of length N with values 0, 1, ..., N-1.static String[]fromString(String s) Generate an array of strings from a string.static Integer[]integerPartiallySortedUnique(int N) Generate a partially sorted array with unique elements.static Integer[]Generate a partially sorted array with unique elements.static Integer[]integerRandom(int N, int numValues) Generate an array of length N whose values are chosen uniformly from the range [0,numValues).static Integer[]integerRandom(int N, int minValue, int maxValue) Generate an array of length N whose values are chosen uniformly from the range [minValue,maxValue).static Integer[]integerRandomUnique(int N) Generate a shuffled array of length N with unique values 0, 1, ...static Integer[]integerReverseSortedUnique(int N) Generate an array of length N with values N-1, N-2, ...static Integer[]integerSortedUnique(int N) Generate an array of length N with values 0, 1, ..., N-1.static int[]intPartiallySortedUnique(int N) Generate a partially sorted array with unique elements.static int[]intPartiallySortedUnique2(int N) Generate a partially sorted array with unique elements.static int[]intRandom(int N, int numValues) Generate an array of length N whose values are chosen uniformly from the range [0,numValues).static int[]intRandom(int N, int minValue, int maxValue) Generate an array of length N whose values are chosen uniformly from the range [minValue,maxValue).static int[]intRandomUnique(int N) Generate a shuffled array of length N with unique values 0, 1, ...static int[]intReverseSortedUnique(int N) Generate an array of length N with values N-1, N-2, ...static int[]Generate an array of ints from a string.static int[]intSortedUnique(int N) Generate an array of length N with values 0, 1, ..., N-1.static voidprint(boolean[] a) Print an array of booleans to standard output.static voidprint(boolean[][] a) Print the M-by-N array of booleans to standard output.static voidprint(double[] a) Print an array of doubles to standard output.static voidprint(double[][] a) Print the M-by-N array of doubles to standard output.static voidprint(int[] a) Print an array of ints to standard output.static voidprint(int[][] a) Print the M-by-N array of ints to standard output.static voidPrint an array of Strings to standard output.static voidPrint the M-by-N array of Strings to standard output.static boolean[]readBoolean1D(String fileName) Read in and return an array of booleans from fileName.static boolean[]readBoolean1D(In in) Read in and return an array of booleans from in.static boolean[][]readBoolean2D(String fileName) Read in and return an M-by-N array of booleans from fileName.static boolean[][]readBoolean2D(In in) Read in and return an M-by-N array of booleans from in.static double[]readDouble1D(String fileName) Read in and return an array of doubles from fileName.static double[]readDouble1D(In in) Read in and return an array of doubles from in.static double[][]readDouble2D(String fileName) Read in and return an M-by-N array of doubles from fileName.static double[][]readDouble2D(In in) Read in and return an M-by-N array of doubles from in.static int[]Read in and return an array of ints from fileName.static int[]Read in and return an array of ints from in.static int[][]Read in and return an M-by-N array of ints from fileName.static int[][]Read in and return an M-by-N array of ints from in.static String[]readString1D(String fileName) Read in and return an array of Strings from fileName.static String[]readString1D(In in) Read in and return an array of Strings from in.static String[][]readString2D(String fileName) Read in and return an M-by-N array of Strings from fileName.static String[][]readString2D(In in) Read in and return an M-by-N array of Strings from in.
-
Constructor Details
-
ArrayGenerator
public ArrayGenerator()
-
-
Method Details
-
fromString
Generate an array of strings from a string. Each array element will be a string of length one. For examplefromString("DOG") generates the array { "D", "O", "G" }- See Also:
-
doublesFromString
Generate an array of doubles from a string. The string should include a list of numbers, separated by single spaces. For exampledoublesFromString("10.3 -Infinity 11)" generates the array { 10.3, -Infinity, 11.0 }- See Also:
-
intsFromString
Generate an array of ints from a string. The string should include a list of numbers, separated by single spaces. For exampledoublesFromString("10 11)" generates the array { 10, 11.0 }- See Also:
-
intRandom
Generate an array of length N whose values are chosen uniformly from the range [minValue,maxValue). -
intRandom
Generate an array of length N whose values are chosen uniformly from the range [0,numValues). -
intSortedUnique
Generate an array of length N with values 0, 1, ..., N-1. -
intReverseSortedUnique
Generate an array of length N with values N-1, N-2, ... 0. -
intRandomUnique
Generate a shuffled array of length N with unique values 0, 1, ... N-1 -
intPartiallySortedUnique
Generate a partially sorted array with unique elements. The number of inversions will be between N and 2N. This algorithm moves random elements an arbitrary amount until the threshold is achieved. -
intPartiallySortedUnique2
Generate a partially sorted array with unique elements. The number of inversions will be between N and 2N. This algorithm moves all elements a small amount. -
integerRandom
Generate an array of length N whose values are chosen uniformly from the range [minValue,maxValue). -
integerRandom
Generate an array of length N whose values are chosen uniformly from the range [0,numValues). -
integerSortedUnique
Generate an array of length N with values 0, 1, ..., N-1. -
integerReverseSortedUnique
Generate an array of length N with values N-1, N-2, ... 0. -
integerRandomUnique
Generate a shuffled array of length N with unique values 0, 1, ... N-1 -
integerPartiallySortedUnique
Generate a partially sorted array with unique elements. The number of inversions will be between N and 2N. This algorithm moves random elements an arbitrary amount until the threshold is achieved. -
integerPartiallySortedUnique2
Generate a partially sorted array with unique elements. The number of inversions will be between N and 2N. This algorithm moves all elements a small amount. -
doubleRandom
Generate an array of length N whose values are chosen uniformly from the range [0,numValues). -
doubleSortedUnique
Generate an array of length N with values 0, 1, ..., N-1. -
doubleReverseSortedUnique
Generate an array of length N with values N-1, N-2, ... 0. -
doubleRandomUnique
Generate a shuffled array of length N with unique values 0, 1, ... N-1 -
doublePartiallySortedUnique
Generate a partially sorted array with unique elements. The number of inversions will be between N and 2N. This algorithm moves random elements an arbitrary amount until the threshold is achieved. -
doublePartiallySortedUnique2
Generate a partially sorted array with unique elements. The number of inversions will be between N and 2N. This algorithm moves all elements a small amount. -
readString1D
Read in and return an array of Strings from fileName. Input must begin with dimensions.- See Also:
-
readString1D
Read in and return an array of Strings from in. Input must begin with dimensions.- See Also:
-
print
Print an array of Strings to standard output. -
readString2D
Read in and return an M-by-N array of Strings from fileName. Input must begin with dimensions. -
readString2D
Read in and return an M-by-N array of Strings from in. Input must begin with dimensions. -
print
Print the M-by-N array of Strings to standard output. -
readDouble1D
Read in and return an array of doubles from fileName. Input must begin with dimensions.- See Also:
-
readDouble1D
Read in and return an array of doubles from in. Input must begin with dimensions.- See Also:
-
print
Print an array of doubles to standard output. -
readDouble2D
Read in and return an M-by-N array of doubles from fileName. Input must begin with dimensions. -
readDouble2D
Read in and return an M-by-N array of doubles from in. Input must begin with dimensions. -
print
Print the M-by-N array of doubles to standard output. -
readInt1D
Read in and return an array of ints from fileName. Input must begin with dimensions.- See Also:
-
readInt1D
Read in and return an array of ints from in. Input must begin with dimensions.- See Also:
-
print
Print an array of ints to standard output. -
readInt2D
Read in and return an M-by-N array of ints from fileName. Input must begin with dimensions. -
readInt2D
Read in and return an M-by-N array of ints from in. Input must begin with dimensions. -
print
Print the M-by-N array of ints to standard output. -
readBoolean1D
Read in and return an array of booleans from fileName. Input must begin with dimensions. -
readBoolean1D
Read in and return an array of booleans from in. Input must begin with dimensions. -
print
Print an array of booleans to standard output. -
readBoolean2D
Read in and return an M-by-N array of booleans from fileName. Input must begin with dimensions. -
readBoolean2D
Read in and return an M-by-N array of booleans from in. Input must begin with dimensions. -
print
Print the M-by-N array of booleans to standard output.
-