@Test public void testIntegers(){ show(Integers(10, 1,2)); }
public static Integer[] Integers(int size, int lo, int hi) { if (size < 0) { throw new IllegalArgumentException("size can not be less than 0"); } if (lo > hi) { throw new IllegalArgumentException("lo can not be larger than hi"); } if (hi > Integer.MAX_VALUE) { throw new IllegalArgumentException("hi can not be larger than Integer.MAX_VALUE"); } Integer[] arr = new Integer[size]; for (int i = 0; i < size; i++) { arr[i] = StdRandom.uniform(lo, hi + 1); } return arr; }
ArrayGenerator { public static Integer[] Integers(int size, int lo, int hi) { if (size < 0) { throw new IllegalArgumentException("size can not be less than 0"); } if (lo > hi) { throw new IllegalArgumentException("lo can not be larger than hi"); } if (hi > Integer.MAX_VALUE) { throw new IllegalArgumentException("hi can not be larger than Integer.MAX_VALUE"); } Integer[] arr = new Integer[size]; for (int i = 0; i < size; i++) { arr[i] = StdRandom.uniform(lo, hi + 1); } return arr; } }
ArrayGenerator { public static Integer[] Integers(int size, int lo, int hi) { if (size < 0) { throw new IllegalArgumentException("size can not be less than 0"); } if (lo > hi) { throw new IllegalArgumentException("lo can not be larger than hi"); } if (hi > Integer.MAX_VALUE) { throw new IllegalArgumentException("hi can not be larger than Integer.MAX_VALUE"); } Integer[] arr = new Integer[size]; for (int i = 0; i < size; i++) { arr[i] = StdRandom.uniform(lo, hi + 1); } return arr; } ArrayGenerator(); }
ArrayGenerator { public static Integer[] Integers(int size, int lo, int hi) { if (size < 0) { throw new IllegalArgumentException("size can not be less than 0"); } if (lo > hi) { throw new IllegalArgumentException("lo can not be larger than hi"); } if (hi > Integer.MAX_VALUE) { throw new IllegalArgumentException("hi can not be larger than Integer.MAX_VALUE"); } Integer[] arr = new Integer[size]; for (int i = 0; i < size; i++) { arr[i] = StdRandom.uniform(lo, hi + 1); } return arr; } ArrayGenerator(); static double[] genRandomDoules(int N, double lower, double upper); static Integer[] duplicateKeysIntArray(int size, int keys); static Integer[] randomIntArray(int hi); static Integer[] randomIntArray(int lo, int hi); static Integer[] ascIntArray(int lo, int hi); static int[] ascInts(int hi); static int[] ascInts(int lo, int hi); static int[] ascInts(int lo, int hi, int num); static double[] randomDoubleArray(int hi, int size); static int[] randomIntsArray(int hi); static int[] randomIntsArray(int lo, int hi); static Integer[] ascIntArray(int hi); static Integer[] descIntArray(int lo, int hi); static Integer[] descIntArray(int hi); static Integer[] fixedValueIntArray(int val, int size); static Integer[] stringToIntArray(String str); static Integer[] Integers(int size, int lo, int hi); static int[] intsArray(int size, int lo, int hi); static Integer[] Integers(int size, int hi); static void show(Object[] a); static int[] allSameInts(int size, int key); static Integer[] intsToInteger(int[] arr); static int[] intsWithNkeys(int size, int... keys); }
ArrayGenerator { public static Integer[] Integers(int size, int lo, int hi) { if (size < 0) { throw new IllegalArgumentException("size can not be less than 0"); } if (lo > hi) { throw new IllegalArgumentException("lo can not be larger than hi"); } if (hi > Integer.MAX_VALUE) { throw new IllegalArgumentException("hi can not be larger than Integer.MAX_VALUE"); } Integer[] arr = new Integer[size]; for (int i = 0; i < size; i++) { arr[i] = StdRandom.uniform(lo, hi + 1); } return arr; } ArrayGenerator(); static double[] genRandomDoules(int N, double lower, double upper); static Integer[] duplicateKeysIntArray(int size, int keys); static Integer[] randomIntArray(int hi); static Integer[] randomIntArray(int lo, int hi); static Integer[] ascIntArray(int lo, int hi); static int[] ascInts(int hi); static int[] ascInts(int lo, int hi); static int[] ascInts(int lo, int hi, int num); static double[] randomDoubleArray(int hi, int size); static int[] randomIntsArray(int hi); static int[] randomIntsArray(int lo, int hi); static Integer[] ascIntArray(int hi); static Integer[] descIntArray(int lo, int hi); static Integer[] descIntArray(int hi); static Integer[] fixedValueIntArray(int val, int size); static Integer[] stringToIntArray(String str); static Integer[] Integers(int size, int lo, int hi); static int[] intsArray(int size, int lo, int hi); static Integer[] Integers(int size, int hi); static void show(Object[] a); static int[] allSameInts(int size, int key); static Integer[] intsToInteger(int[] arr); static int[] intsWithNkeys(int size, int... keys); static Random random; }