Beispiel #1
0
 /**
  * Return {@link empty_#getEmpty$ empty} or an {@link ArraySequence} wrapping the given elements,
  * depending on whether the given array and varargs are empty
  *
  * @param rest The elements at the end of the sequence
  * @param elements the elements at the start of the sequence
  * @return A Sequential
  */
 public static <T> Sequential<? extends T> sequentialInstance(
     TypeDescriptor $reifiedT, Sequential<? extends T> rest, T... elements) {
   if (elements.length == 0) {
     if (rest.getEmpty()) {
       return (Sequential) empty_.getEmpty$();
     }
     return rest;
   }
   // elements is not empty
   if (rest.getEmpty()) return ArraySequence.<T>instance($reifiedT, elements);
   // we have both, let's find the total size
   int total = (int) (rest.getSize() + elements.length);
   java.lang.Object[] newArray = new java.lang.Object[total];
   System.arraycopy(elements, 0, newArray, 0, elements.length);
   Iterator<? extends T> iterator = rest.iterator();
   int i = elements.length;
   for (Object elem; (elem = iterator.next()) != finished_.getFinished$(); i++) {
     newArray[i] = elem;
   }
   return ArraySequence.<T>instance($reifiedT, newArray);
 }
Beispiel #2
0
 /**
  * Return {@link empty_#getEmpty$ empty} or an {@link ArraySequence} wrapping the given elements,
  * depending on whether the given array is empty
  *
  * @param elements The elements
  * @return A Sequential
  */
 public static <T> Sequential<T> sequentialInstance(TypeDescriptor $reifiedT, T[] elements) {
   if (elements.length == 0) {
     return (Sequential) empty_.getEmpty$();
   }
   return ArraySequence.<T>instance($reifiedT, elements);
 }