code: @SuppressWarnings("unchecked")
      public T[] nextPermutationAsArray()
      {
          T[] permutation = (T[]) Array.newInstance(elements.getClass().getComponentType(),
                                                    permutationIndices.length);
          return nextPermutationAsArray(permutation);
      }
docs: Generate the next permutation and return an array containing
  the elements in the appropriate order.
  @see #nextPermutationAsArray(Object[])
  @see #nextPermutationAsList()
  @return The next permutation as an array.