public void next() {
        boolean hasLeft = currentLeft != null;
        boolean hasRight = currentRight != null;

        if (!hasLeft && !hasRight) {
            throw new NoSuchElementException();
        }

        int order;
        if (hasLeft && !hasRight) {
            order = -1;
        } else if (!hasLeft) {
            order = 1;
        } else {
            order = comparator.compare(currentLeft, currentRight);
        }

        if (order < 0) {
            reportedLeft = currentLeft;
            currentLeft = nextOrNull(left);
            reportedRight = null;
        } else if (order > 0) {
            reportedLeft = null;
            reportedRight = currentRight;
            currentRight = nextOrNull(right);
        } else {
            reportedLeft = currentLeft;
            reportedRight = currentRight;
            currentLeft = nextOrNull(left);
            currentRight = nextOrNull(right);
        }
    }
public void next ( ) { boolean hasLeft = currentLeft != null ; boolean hasRight = currentRight != null ; if ( ! hasLeft && ! hasRight ) { throw new NoSuchElementException ( ) ; } int order ; if ( hasLeft && ! hasRight ) { order = - 1 ; } else if ( ! hasLeft ) { order = 1 ; } else { order = comparator . compare ( currentLeft , currentRight ) ; } if ( order < 0 ) { reportedLeft = currentLeft ; currentLeft = nextOrNull ( left ) ; reportedRight = null ; } else if ( order > 0 ) { reportedLeft = null ; reportedRight = currentRight ; currentRight = nextOrNull ( right ) ; } else { reportedLeft = currentLeft ; reportedRight = currentRight ; currentLeft = nextOrNull ( left ) ; currentRight = nextOrNull ( right ) ; } }
Use {@link #getLeft()} and {@link #getRight()} to get the next elements from the two iterated collections.