Exemplo n.º 1
1
 @Override
 public Array<T> leftPadTo(int length, T element) {
   final int actualLength = length();
   if (length <= actualLength) {
     return this;
   } else {
     return prependAll(Iterator.continually(element).take(length - actualLength));
   }
 }
Exemplo n.º 2
1
 /**
  * Creates a Array based on the elements of a char array.
  *
  * @param array a char array
  * @return A new Array of Character values
  */
 public static Array<Character> ofAll(char[] array) {
   Objects.requireNonNull(array, "array is null");
   return ofAll(Iterator.ofAll(array));
 }
Exemplo n.º 3
1
 /**
  * Creates a Array of int numbers starting from {@code from}, extending to {@code toExclusive -
  * 1}.
  *
  * <p>Examples:
  *
  * <pre>
  * <code>
  * Array.range(0, 0)  // = Array()
  * Array.range(2, 0)  // = Array()
  * Array.range(-2, 2) // = Array(-2, -1, 0, 1)
  * </code>
  * </pre>
  *
  * @param from the first number
  * @param toExclusive the last number + 1
  * @return a range of int values as specified or the empty range if {@code from >= toExclusive}
  */
 public static Array<Integer> range(int from, int toExclusive) {
   return ofAll(Iterator.range(from, toExclusive));
 }
Exemplo n.º 4
1
 public static Array<Character> range(char from, char toExclusive) {
   return ofAll(Iterator.range(from, toExclusive));
 }
Exemplo n.º 5
1
 /**
  * Creates a Array based on the elements of a short array.
  *
  * @param array a short array
  * @return A new Array of Short values
  */
 public static Array<Short> ofAll(short[] array) {
   Objects.requireNonNull(array, "array is null");
   return ofAll(Iterator.ofAll(array));
 }
Exemplo n.º 6
1
 /**
  * Creates a Array based on the elements of a long array.
  *
  * @param array a long array
  * @return A new Array of Long values
  */
 public static Array<Long> ofAll(long[] array) {
   Objects.requireNonNull(array, "array is null");
   return ofAll(Iterator.ofAll(array));
 }
Exemplo n.º 7
1
 /**
  * Creates a Array based on the elements of an int array.
  *
  * @param array an int array
  * @return A new Array of Integer values
  */
 public static Array<Integer> ofAll(int[] array) {
   Objects.requireNonNull(array, "array is null");
   return ofAll(Iterator.ofAll(array));
 }
Exemplo n.º 8
1
 /**
  * Creates a Array based on the elements of a double array.
  *
  * @param array a double array
  * @return A new Array of Double values
  */
 public static Array<Double> ofAll(double[] array) {
   Objects.requireNonNull(array, "array is null");
   return ofAll(Iterator.ofAll(array));
 }
Exemplo n.º 9
1
 public static Array<Character> rangeClosed(char from, char toInclusive) {
   return ofAll(Iterator.rangeClosed(from, toInclusive));
 }
Exemplo n.º 10
1
 /**
  * Creates a Array of long numbers starting from {@code from}, extending to {@code toExclusive -
  * 1}.
  *
  * <p>Examples:
  *
  * <pre>
  * <code>
  * Array.range(0L, 0L)  // = Array()
  * Array.range(2L, 0L)  // = Array()
  * Array.range(-2L, 2L) // = Array(-2L, -1L, 0L, 1L)
  * </code>
  * </pre>
  *
  * @param from the first number
  * @param toExclusive the last number + 1
  * @return a range of long values as specified or the empty range if {@code from >= toExclusive}
  */
 public static Array<Long> range(long from, long toExclusive) {
   return ofAll(Iterator.range(from, toExclusive));
 }
Exemplo n.º 11
1
 /**
  * Creates a Array of long numbers starting from {@code from}, extending to {@code toInclusive}.
  *
  * <p>Examples:
  *
  * <pre>
  * <code>
  * Array.rangeClosed(0L, 0L)  // = Array(0L)
  * Array.rangeClosed(2L, 0L)  // = Array()
  * Array.rangeClosed(-2L, 2L) // = Array(-2L, -1L, 0L, 1L, 2L)
  * </code>
  * </pre>
  *
  * @param from the first number
  * @param toInclusive the last number
  * @return a range of long values as specified or the empty range if {@code from > toInclusive}
  */
 public static Array<Long> rangeClosed(long from, long toInclusive) {
   return ofAll(Iterator.rangeClosed(from, toInclusive));
 }
Exemplo n.º 12
1
 /**
  * Creates a Array based on the elements of a boolean array.
  *
  * @param array a boolean array
  * @return A new Array of Boolean values
  */
 public static Array<Boolean> ofAll(boolean[] array) {
   Objects.requireNonNull(array, "array is null");
   return ofAll(Iterator.ofAll(array));
 }
Exemplo n.º 13
1
 /**
  * Creates a Array of int numbers starting from {@code from}, extending to {@code toInclusive}.
  *
  * <p>Examples:
  *
  * <pre>
  * <code>
  * Array.rangeClosed(0, 0)  // = Array(0)
  * Array.rangeClosed(2, 0)  // = Array()
  * Array.rangeClosed(-2, 2) // = Array(-2, -1, 0, 1, 2)
  * </code>
  * </pre>
  *
  * @param from the first number
  * @param toInclusive the last number
  * @return a range of int values as specified or the empty range if {@code from > toInclusive}
  */
 public static Array<Integer> rangeClosed(int from, int toInclusive) {
   return ofAll(Iterator.rangeClosed(from, toInclusive));
 }
Exemplo n.º 14
0
 /**
  * Creates a Array of long numbers starting from {@code from}, extending to {@code toInclusive},
  * with {@code step}.
  *
  * <p>Examples:
  *
  * <pre>
  * <code>
  * Array.rangeClosedBy(1L, 3L, 1L)  // = Array(1L, 2L, 3L)
  * Array.rangeClosedBy(1L, 4L, 2L)  // = Array(1L, 3L)
  * Array.rangeClosedBy(4L, 1L, -2L) // = Array(4L, 2L)
  * Array.rangeClosedBy(4L, 1L, 2L)  // = Array()
  * </code>
  * </pre>
  *
  * @param from the first number
  * @param toInclusive the last number
  * @param step the step
  * @return a range of int values as specified or the empty range if<br>
  *     {@code from > toInclusive} and {@code step > 0} or<br>
  *     {@code from < toInclusive} and {@code step < 0}
  * @throws IllegalArgumentException if {@code step} is zero
  */
 public static Array<Long> rangeClosedBy(long from, long toInclusive, long step) {
   return ofAll(Iterator.rangeClosedBy(from, toInclusive, step));
 }
Exemplo n.º 15
0
 /**
  * Creates a Array of int numbers starting from {@code from}, extending to {@code toInclusive},
  * with {@code step}.
  *
  * <p>Examples:
  *
  * <pre>
  * <code>
  * Array.rangeClosedBy(1, 3, 1)  // = Array(1, 2, 3)
  * Array.rangeClosedBy(1, 4, 2)  // = Array(1, 3)
  * Array.rangeClosedBy(4, 1, -2) // = Array(4, 2)
  * Array.rangeClosedBy(4, 1, 2)  // = Array()
  * </code>
  * </pre>
  *
  * @param from the first number
  * @param toInclusive the last number
  * @param step the step
  * @return a range of int values as specified or the empty range if<br>
  *     {@code from > toInclusive} and {@code step > 0} or<br>
  *     {@code from < toInclusive} and {@code step < 0}
  * @throws IllegalArgumentException if {@code step} is zero
  */
 public static Array<Integer> rangeClosedBy(int from, int toInclusive, int step) {
   return ofAll(Iterator.rangeClosedBy(from, toInclusive, step));
 }
Exemplo n.º 16
0
 public static Array<Double> rangeClosedBy(double from, double toInclusive, double step) {
   return ofAll(Iterator.rangeClosedBy(from, toInclusive, step));
 }
Exemplo n.º 17
0
 public static Array<Character> rangeClosedBy(char from, char toInclusive, int step) {
   return ofAll(Iterator.rangeClosedBy(from, toInclusive, step));
 }