@Override
    public Stream<List<T>> combinations() {
        if (this instanceof ArrayStream) {
            @SuppressWarnings("resource")
            final ArrayStream<T> s = ((ArrayStream<T>) this);
            final int count = s.toIndex - s.fromIndex;

            return newStream(IntStream.rangeClosed(0, count).flatMapToObj(new IntFunction<Stream<List<T>>>() {
                @Override
                public Stream<List<T>> apply(int value) {
                    return combinations(value);
                }
            }).iterator(), false, null);
        } else {
            return newStream((T[]) toArray(), false, null).combinations();
        }
    }
@ Override public Stream < List < T > > combinations ( ) { if ( this instanceof ArrayStream ) { @ SuppressWarnings ( "resource" ) final ArrayStream < T > s = ( ( ArrayStream < T > ) this ) ; final int count = s . toIndex - s . fromIndex ; return newStream ( IntStream . rangeClosed ( 0 , count ) . flatMapToObj ( new IntFunction < Stream < List < T > > > ( ) { @ Override public Stream < List < T > > apply ( int value ) { return combinations ( value ) ; } } ) . iterator ( ) , false , null ) ; } else { return newStream ( ( T [ ] ) toArray ( ) , false , null ) . combinations ( ) ; } }
}