public static <A, B> BiIterator<A, B> generate(final BooleanSupplier hasNext, final Consumer<Pair<A, B>> output) {
        N.checkArgNotNull(hasNext);
        N.checkArgNotNull(output);

        return new BiIterator<A, B>() {
            private final Pair<A, B> tmp = new Pair<A, B>();

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

            @Override
            public Pair<A, B> next() {
                if (hasNext() == false) {
                    throw new NoSuchElementException();
                }

                output.accept(tmp);

                return Pair.of(tmp.left, tmp.right);
            }

            @Override
            public <E extends Exception> void forEachRemaining(final Try.BiConsumer<? super A, ? super B, E> action) throws E {
                N.checkArgNotNull(action);

                while (hasNext.getAsBoolean()) {
                    output.accept(tmp);

                    action.accept(tmp.left, tmp.right);
                }
            }

            @Override
            public <R> ObjIterator<R> map(final BiFunction<? super A, ? super B, R> mapper) {
                N.checkArgNotNull(mapper);

                return new ObjIterator<R>() {
                    @Override
                    public boolean hasNext() {
                        return hasNext.getAsBoolean();
                    }

                    @Override
                    public R next() {
                        if (hasNext() == false) {
                            throw new NoSuchElementException();
                        }

                        output.accept(tmp);

                        return mapper.apply(tmp.left, tmp.right);
                    }
                };
            }
        };
    }
public static < A , B > BiIterator < A , B > generate ( final BooleanSupplier hasNext , final Consumer < Pair < A , B > > output ) { N . checkArgNotNull ( hasNext ) ; N . checkArgNotNull ( output ) ; return new BiIterator < A , B > ( ) { private final Pair < A , B > tmp = new Pair < A , B > ( ) ; @ Override public boolean hasNext ( ) { return hasNext . getAsBoolean ( ) ; } @ Override public Pair < A , B > next ( ) { if ( hasNext ( ) == false ) { throw new NoSuchElementException ( ) ; } output . accept ( tmp ) ; return Pair . of ( tmp . left , tmp . right ) ; } @ Override public < E extends Exception > void forEachRemaining ( final Try . BiConsumer < ? super A , ? super B , E > action ) throws E { N . checkArgNotNull ( action ) ; while ( hasNext . getAsBoolean ( ) ) { output . accept ( tmp ) ; action . accept ( tmp . left , tmp . right ) ; } } @ Override public < R > ObjIterator < R > map ( final BiFunction < ? super A , ? super B , R > mapper ) { N . checkArgNotNull ( mapper ) ; return new ObjIterator < R > ( ) { @ Override public boolean hasNext ( ) { return hasNext . getAsBoolean ( ) ; } @ Override public R next ( ) { if ( hasNext ( ) == false ) { throw new NoSuchElementException ( ) ; } output . accept ( tmp ) ; return mapper . apply ( tmp . left , tmp . right ) ; } } ; } } ; }
@param hasNext
@param output
@return