code: @NotNull
      public <R> R[] toArray(@NotNull IntFunction<R[]> generator) {
          return Operators.toArray(iterator, generator);
      }
docs: Collects elements to an array, the {@code generator} constructor of provided.
  
  <p>This is a terminal operation.
  
  @param <R> the type of the result
  @param generator  the array constructor reference that accommodates future array of assigned size
  @return the result of collect elements