Start a reactive flow from a Collection using an Iterator

@param collection - Collection SimpleReact will iterate over at the skip of the flow

@return Next stage in the reactive flow
171196
@SuppressWarnings("unchecked")
    public <R> SimpleReactStream<R> from(final Collection<R> collection) {
        return from(collection.stream());
    }
1261525
public static TransactionAware of(Collection<TransactionAware> transactionAwares) {
    // this is most common case, trying to optimize
    if (transactionAwares.size() == 1) {
      return transactionAwares.iterator().next();
    }

    TransactionAwareCollection result = new TransactionAwareCollection();
    result.addAll(transactionAwares);

    return result;
  }
713297
public Stream<T> onNext(final Action1<? super T> action) {
        return new Stream<T>() {
            @Override
            public Iterator<T> iterator() {
                return new ReadOnlyIterator<T>() {

                    Iterator<T> iterator = Stream.this.iterator();

                    @Override
                    public boolean hasNext() {
                        return iterator.hasNext();
                    }

                    @Override
                    public T next() {
                        final T next = iterator.next();
                        action.call(next);
                        return next;
                    }
                };
            }
        };
    }
512026
public static <E> Collection<E> createLazyCollectionFromStream(Supplier<Stream<E>> sequentialStreamSupplier, int size)
  {
    return new AbstractCollection<E>()
    {
      @Override
      public Iterator<E> iterator()
      {
        return sequentialStreamSupplier.get().iterator();
      }

      @Override
      public Spliterator<E> spliterator()
      {
        return sequentialStreamSupplier.get().spliterator();
      }

      @Override
      public Stream<E> stream()
      {
        return sequentialStreamSupplier.get();
      }

      @Override
      public Stream<E> parallelStream()
      {
        return sequentialStreamSupplier.get().parallel();
      }

      @Override
      public int size()
      {
        return size;
      }
    };
  }
252165
public static <T> Iterator<T> join(Collection<Iterable<T>> iterables) {
        Queue<Iterator<T>> iters = 
            new ArrayDeque<Iterator<T>>(iterables.size());
        for (Iterable<T> i : iterables)
            iters.add(i.iterator());
        return new CombinedIterator<T>(iters);
    }
641815
private List<Integer> getRunningFlowsHelper(final int projectId, final String flowId,
      final Collection<Pair<ExecutionReference, ExecutableFlow>> collection) {
    final List<Integer> executionIds = new ArrayList<>();
    for (final Pair<ExecutionReference, ExecutableFlow> ref : collection) {
      if (ref.getSecond().getFlowId().equals(flowId)
          && ref.getSecond().getProjectId() == projectId) {
        executionIds.add(ref.getFirst().getExecId());
      }
    }
    return executionIds;
  }
26814
public static Collection<?> getEmptyImplementationForCollectionInterface(final Class<?> collectionInterface) {
        Collection<?> collection = new ArrayList<>();
        if (List.class.isAssignableFrom(collectionInterface)) {
            collection = new ArrayList<>();
        } else if (NavigableSet.class.isAssignableFrom(collectionInterface)) {
            collection = new TreeSet<>();
        } else if (SortedSet.class.isAssignableFrom(collectionInterface)) {
            collection = new TreeSet<>();
        } else if (Set.class.isAssignableFrom(collectionInterface)) {
            collection = new HashSet<>();
        } else if (BlockingDeque.class.isAssignableFrom(collectionInterface)) {
            collection = new LinkedBlockingDeque<>();
        } else if (Deque.class.isAssignableFrom(collectionInterface)) {
            collection = new ArrayDeque<>();
        } else if (TransferQueue.class.isAssignableFrom(collectionInterface)) {
            collection = new LinkedTransferQueue<>();
        } else if (BlockingQueue.class.isAssignableFrom(collectionInterface)) {
            collection = new LinkedBlockingQueue<>();
        } else if (Queue.class.isAssignableFrom(collectionInterface)) {
            collection = new LinkedList<>();
        }
        return collection;
    }
591623
public static <T> ArrayList<T> newArrayList(Collection<T> collection) {
		return (ArrayList<T>) list(false, collection);
	}
1125278
public static final <A> Collection<A> toLazyCollection(final Stream<A> stream) {
        return SeqUtils.toLazyCollection(stream.iterator());
    }
389703
public static <E extends Comparable<? super E>> E min(final Collection<E> collection) {
        return Collections.min(collection);
    }
17038
public static final <A> Collection<A> toConcurrentLazyCollection(final Stream<A> stream) {
        return toConcurrentLazyCollection(stream.iterator());
    }
620675
public static <T> List<T> convertCollectionToList(final Collection<T> collection) {

        if(List.class.isAssignableFrom(collection.getClass())) {
            return (List<T>)collection;
        }

        return new ArrayList<>(collection);

    }
657569
public static <T> Stream<T> buildReversedStream(Collection<T> collection) {
        return JMCollections.getReversed(collection).stream();
    }
105786
public static <T> Map<T, Long> countBy(Collection<T> collection) {
        return countBy(collection.stream());
    }
495866
public static <K, V> Map<K, V> newMap(
            Collection<Map.Entry<K, V>> collection) {
        return collection.stream()
                .collect(toMap(Map.Entry::getKey, Map.Entry::getValue));
    }
942759
protected Object add(Object list, Collection collection)
    {
        Iterator i=collection.iterator();
        while(i.hasNext())
            list=LazyList.add(list,i.next());
        return list;
    }
1251802
public static <T> List<T> toList(final Collection<T> collection) {

        if (isEmpty(collection)) {
            return new ArrayList<T>(0);
        } else {
            return new ArrayList<T>(collection);
        }
    }