<pre>
{@code
assertThat(Streams.flatMapStream(Stream.of(1,2,3),
i->Stream.of(i)).collect(CyclopsCollectors.toList()),
equalTo(Arrays.asList(1,2,3)));


}
</pre>
504164
public final static <T, R> Stream<R> flatMapStream(final Stream<T> stream, final Function<? super T, ? extends BaseStream<? extends R, ?>> fn) {
        return stream.flatMap(fn.andThen(bs -> {

            if (bs instanceof Stream)
                return (Stream<R>) bs;
            else
                return Streams.stream(bs.iterator());

        }));
    }
1138679
private void collect(PrintStream out, List<ItemSet> list, TotalSupportTree ttree, int[] itemset, int support) {
        if (list != null) {
            synchronized (list) {
                list.add(new ItemSet(itemset, support));
            }
        }
        if (out != null) {
            synchronized (out) {
                for (int i = 0; i < itemset.length; i++) {
                    out.format("%d ", itemset[i]);
                }
                out.format("(%d)%n", support);
            }
        }
        if (ttree != null) {
            synchronized (ttree) {
                ttree.add(itemset, support);
            }
        }
    }
184452
@GwtIncompatible
  public static PathSubject assertThat(@NullableDecl Path target) {
    return assertAbout(PathSubject.paths()).that(target);
  }
927113
public static <T> Collector<T, ?, T> toOneElement() {
    return java.util.stream.Collectors.collectingAndThen(
      java.util.stream.Collectors.toList(),
      list -> {
        if (list.size() != 1) {
          throw new IllegalStateException("Stream should have only one element");
        }
        return list.get(0);
      });
  }
810936
public <T> void assertThat(T actual, org.hamcrest.Matcher<? super T> matcher) {
    try {
      org.hamcrest.MatcherAssert.assertThat(actual, matcher);
    } catch (AssertionError e) {
      fail(e);
    }
  }
1133770
@SuppressWarnings("unchecked")
    public <R> FutureStream<R> from(final Collection<R> collection) {
        return fromStream(collection.stream());
    }
1198210
@Override
    public <X> LazyCollectionX<X> fromStream(final ReactiveSeq<X> stream) {
        return ListX.fromIterable(stream.collect(Collectors.toList()));
    }
1003022
private static <T> Stream<T> enumerationAsStream(Enumeration<? extends T> e)
    {
        Iterator<T> iterator = new Iterator<T>()
        {
            @Override
            public T next()
            {
                return e.nextElement();
            }

            @Override
            public boolean hasNext()
            {
                return e.hasMoreElements();
            }
        };
        return StreamSupport.stream(
            Spliterators.spliteratorUnknownSize(
                iterator, Spliterator.ORDERED), false);
    }
835786
public static <T, C extends Collection<T>> Stream<T>
    ifExistIntoStream(C collection) {
        return getOptional(collection).map(Collection::stream)
                .orElseGet(Stream::empty);
    }
589756
public JsonAssert and(JsonAssertion... assertions) {
        Arrays.stream(assertions).forEach(a -> a.doAssert(this));
        return this;
    }
983169
@SuppressWarnings("unchecked")
    public static <T> ReactiveSeq<T> takeUntil(final Stream<T> stream, final Predicate<? super T> predicate) {
        final Iterator<T> it = stream.iterator();

        class LimitUntil implements Iterator<T> {
            T next = (T) NULL;
            boolean test = false;

            void test() {
                if (!test && next == NULL && it.hasNext()) {
                    next = it.next();

                    if (test = predicate.test(next)) {
                        next = (T) NULL;
                        close(it); // need to close any open queues
                    }
                }
            }

            @Override
            public boolean hasNext() {
                test();
                return next != NULL;
            }

            @Override
            public T next() {
                if (next == NULL)
                    throw new NoSuchElementException();

                try {
                    return next;
                } finally {
                    next = (T) NULL;
                }
            }
        }

        return ReactiveSeq.fromIterator(new LimitUntil())
                  .onClose(() -> {
                      stream.close();
                  });
    }
1073066
public static <T> Collector<T, Set<T>> toSet() {
    return new Collector<T, Set<T>>() {
      @Override
      public Set<T> collect(Stream<? extends T> stream) {
        return Sets.newHashSet(stream.iterator());
      }
    };
  }
65864
public CTX as(@Nonnull java.util.function.Consumer<RS> assertions) {
        return to(assertions);
    }
683229
public <T0, T1, T2, T3> SingleOutputStreamOperator<Tuple4<T0, T1, T2, T3>> projectTuple4() {
		TypeInformation<?>[] fTypes = extractFieldTypes(fieldIndexes, dataStream.getType());
		TupleTypeInfo<Tuple4<T0, T1, T2, T3>> tType = new TupleTypeInfo<Tuple4<T0, T1, T2, T3>>(fTypes);

		return dataStream.transform("Projection", tType, new StreamProject<IN, Tuple4<T0, T1, T2, T3>>(fieldIndexes, tType.createSerializer(dataStream.getExecutionConfig())));
	}
625031
@Override
	protected List<OUT> executeOnCollections(List<IN> input, RuntimeContext ctx, ExecutionConfig executionConfig) throws Exception {
		FlatMapFunction<IN, OUT> function = userFunction.getUserCodeObject();
		
		FunctionUtils.setFunctionRuntimeContext(function, ctx);
		FunctionUtils.openFunction(function, parameters);

		ArrayList<OUT> result = new ArrayList<OUT>(input.size());

		TypeSerializer<IN> inSerializer = getOperatorInfo().getInputType().createSerializer(executionConfig);
		TypeSerializer<OUT> outSerializer = getOperatorInfo().getOutputType().createSerializer(executionConfig);

		CopyingListCollector<OUT> resultCollector = new CopyingListCollector<OUT>(result, outSerializer);

		for (IN element : input) {
			IN inCopy = inSerializer.copy(element);
			function.flatMap(inCopy, resultCollector);
		}

		FunctionUtils.closeFunction(function);

		return result;
	}
929849
public static <T> Collector<T, ?, ArrayList<T>> toArrayList() {
    return java.util.stream.Collectors.toCollection(ArrayList::new);
  }
556885
public Stream<TreeMatchResult<V>> results() {
		return _tree.stream()
			.flatMap((Tree<V, ?> tree) -> _pattern.match(tree, _equals)
				.map(Stream::of)
				.orElseGet(Stream::empty));
	}