@Override
    public <R> Stream<R> slidingMap(final BiFunction<? super T, ? super T, R> mapper, final int increment, final boolean ignoreNotPaired) {
        final int windowSize = 2;

        checkArgPositive(increment, "increment");

        return newStream(new ObjIteratorEx<R>() {
            private int cursor = fromIndex;

            @Override
            public boolean hasNext() {
                return ignoreNotPaired ? toIndex - cursor >= windowSize : cursor < toIndex;
            }

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

                final R result = mapper.apply(elements[cursor], cursor < toIndex - 1 ? elements[cursor + 1] : null);

                cursor = increment < toIndex - cursor && windowSize < toIndex - cursor ? cursor + increment : toIndex;

                return result;
            }

            //    @Override
            //    public long count() {
            //        if (toIndex - cursor == 0) {
            //            return 0;
            //        } else if (toIndex - cursor <= windowSize) {
            //            return 1;
            //        } else {
            //            final long len = (toIndex - cursor) - windowSize;
            //            return 1 + (len % increment == 0 ? len / increment : len / increment + 1);
            //        }
            //    }
            //
            //    @Override
            //    public void skip(long n) {
            //        checkArgNotNegative(n, "n");
            //
            //        if (n >= count()) {
            //            cursor = toIndex;
            //        } else {
            //            cursor += n * increment;
            //        }
            //    }
        }, false, null);
    }
@ Override public < R > Stream < R > slidingMap ( final BiFunction < ? super T , ? super T , R > mapper , final int increment , final boolean ignoreNotPaired ) { final int windowSize = 2 ; checkArgPositive ( increment , "increment" ) ; return newStream ( new ObjIteratorEx < R > ( ) { private int cursor = fromIndex ; @ Override public boolean hasNext ( ) { return ignoreNotPaired ? toIndex - cursor >= windowSize : cursor < toIndex ; } @ Override public R next ( ) { if ( hasNext ( ) == false ) { throw new NoSuchElementException ( ) ; } final R result = mapper . apply ( elements [ cursor ] , cursor < toIndex - 1 ? elements [ cursor + 1 ] : null ) ; cursor = increment < toIndex - cursor && windowSize < toIndex - cursor ? cursor + increment : toIndex ; return result ; } } , false , null ) ; }
}