public RangeSet complement ( ) { SortedSet < CharRange > nset = new TreeSet < CharRange > ( ) ; int from = 0 ; for ( CharRange r : set ) { int to = r . getFrom ( ) ; if ( from < to ) { nset . add ( new CharRange ( from , to ) ) ; } from = r . getTo ( ) ; } if ( from < Integer . MAX_VALUE ) { nset . add ( new CharRange ( from , Integer . MAX_VALUE ) ) ; } return new RangeSet ( nset ) ; }
Return a complement RangeSet . In other words a RangeSet doesn t accept any of this rangesets characters and accepts all other characters .