code: @Nullable
      public <R, A> R collect(@NotNull Collector<? super T, A, R> collector) {
          A container = collector.supplier().get();
          while (iterator.hasNext()) {
              final T value = iterator.next();
              collector.accumulator().accept(container, value);
          }
          return collector.finisher().apply(container);
      }
docs: Collects elements with {@code collector} that encapsulates supplier, accumulator and combiner functions.
  
  <p>This is a terminal operation.
  
  @param <R> the type of result
  @param <A> the intermediate used by {@code Collector}
  @param collector  the {@code Collector}
  @return the result of collect elements
  @see #collect(com.annimon.stream.function.Supplier, com.annimon.stream.function.BiConsumer)