public static FloatStream iterate(final float init, final FloatPredicate hasNext, final FloatUnaryOperator f) {
        N.checkArgNotNull(hasNext);
        N.checkArgNotNull(f);

        return new IteratorFloatStream(new FloatIteratorEx() {
            private float t = 0;
            private float cur = 0;
            private boolean isFirst = true;
            private boolean hasMore = true;
            private boolean hasNextVal = false;

            @Override
            public boolean hasNext() {
                if (hasNextVal == false && hasMore) {
                    if (isFirst) {
                        isFirst = false;
                        hasNextVal = hasNext.test(cur = init);
                    } else {
                        hasNextVal = hasNext.test(cur = f.applyAsFloat(t));
                    }

                    if (hasNextVal == false) {
                        hasMore = false;
                    }
                }

                return hasNextVal;
            }

            @Override
            public float nextFloat() {
                if (hasNextVal == false && hasNext() == false) {
                    throw new NoSuchElementException();
                }

                t = cur;
                hasNextVal = false;
                return t;
            }
        });
    }
public static FloatStream iterate ( final float init , final FloatPredicate hasNext , final FloatUnaryOperator f ) { N . checkArgNotNull ( hasNext ) ; N . checkArgNotNull ( f ) ; return new IteratorFloatStream ( new FloatIteratorEx ( ) { private float t = 0 ; private float cur = 0 ; private boolean isFirst = true ; private boolean hasMore = true ; private boolean hasNextVal = false ; @ Override public boolean hasNext ( ) { if ( hasNextVal == false && hasMore ) { if ( isFirst ) { isFirst = false ; hasNextVal = hasNext . test ( cur = init ) ; } else { hasNextVal = hasNext . test ( cur = f . applyAsFloat ( t ) ) ; } if ( hasNextVal == false ) { hasMore = false ; } } return hasNextVal ; } @ Override public float nextFloat ( ) { if ( hasNextVal == false && hasNext ( ) == false ) { throw new NoSuchElementException ( ) ; } t = cur ; hasNextVal = false ; return t ; } } ) ; }
@param init
@param hasNext test if has next by hasNext.test(init) for first time and hasNext.test(f.apply(previous)) for remaining.
@param f
@return