public static <T, R extends Iterable<?>> Transformer<T, R> collectWhile(final Func0<R> factory, final Action2<? super R, ? super T> collect, final Func2<? super R, ? super T, Boolean> condition) { Func1<R, Boolean> isEmpty = new Func1<R, Boolean>() { @Override public Boolean call(R collection) { return !collection.iterator().hasNext(); } }; return collectWhile(factory, collect, condition, isEmpty); }
public static <T, R extends Iterable<?>> Transformer<T, R> collectWhile(final Func0<R> factory, final Action2<? super R, ? super T> collect, final Func2<? super R, ? super T, Boolean> condition) { Func1<R, Boolean> isEmpty = new Func1<R, Boolean>() { @Override public Boolean call(R collection) { return !collection.iterator().hasNext(); } }; return collectWhile(factory, collect, condition, isEmpty); }
return collectWhile(initialState, collect, condition);
return collectWhile(initialState, collect, condition);
/** * <p> * Returns a {@link Transformer} that returns an {@link Observable} that is * collected into {@code Collection} instances created by {@code factory} * that are emitted when items are not equal or on completion. * * <p> * <img src= * "https://github.com/davidmoten/rxjava-extras/blob/master/src/docs/collectWhile.png?raw=true" * alt="marble diagram"> * * @param factory * collection instance creator * @param collect * collection action * @param <T> * generic type of source observable * @param <R> * collection type emitted by transformed Observable * @return transformer as above */ public static <T, R extends Collection<T>> Transformer<T, R> collectWhile( final Func0<R> factory, final Action2<? super R, ? super T> collect) { return collectWhile(factory, collect, HolderEquals.<T> instance()); }
/** * <p> * Returns a {@link Transformer} that returns an {@link Observable} that is * collected into {@code Collection} instances created by {@code factory} * that are emitted when items are not equal or on completion. * * <p> * <img src= * "https://github.com/davidmoten/rxjava-extras/blob/master/src/docs/collectWhile.png?raw=true" * alt="marble diagram"> * * @param factory * collection instance creator * @param collect * collection action * @param <T> * generic type of source observable * @param <R> * collection type emitted by transformed Observable * @return transformer as above */ public static <T, R extends Collection<T>> Transformer<T, R> collectWhile( final Func0<R> factory, final Action2<? super R, ? super T> collect) { return collectWhile(factory, collect, HolderEquals.<T> instance()); }