@ SuppressWarnings ( "unchecked" ) public List < Range > without ( Range range ) { if ( ! intersectsWith ( range ) ) return Collections . singletonList ( this ) ; if ( upper <= range . upper ) return range . lower <= lower ? Collections . EMPTY_LIST : Collections . singletonList ( new Range ( lower , range . lower , reversed ) ) ; if ( range . lower <= lower ) return Collections . singletonList ( new Range ( range . upper , upper , reversed ) ) ; return Arrays . asList ( new Range ( lower , range . lower , reversed ) , new Range ( range . upper , upper , reversed ) ) ; }
Subtract provided range and return list of ranges contained in current range and not intersecting with other range .