public boolean containsAll ( UnicodeSet b ) { // The specified set is a subset if all of its pairs are contained in // this set. This implementation accesses the lists directly for speed. // TODO: this could be faster if size() were cached. But that would affect building speed // so it needs investigation. int [ ] listB = b . list ; boolean needA = true ; boolean needB = true ; int aPtr = 0 ; int bPtr = 0 ; int aLen = len - 1 ; int bLen = b . len - 1 ; int startA = 0 , startB = 0 , limitA = 0 , limitB = 0 ; while ( true ) { // double iterations are such a pain... if ( needA ) { if ( aPtr >= aLen ) { // ran out of A. If B is also exhausted, then break; if ( needB && bPtr >= bLen ) { break ; } return false ; } startA = list [ aPtr ++ ] ; limitA = list [ aPtr ++ ] ; } if ( needB ) { if ( bPtr >= bLen ) { // ran out of B. Since we got this far, we have an A and we are ok so far break ; } startB = listB [ bPtr ++ ] ; limitB = listB [ bPtr ++ ] ; } // if B doesn't overlap and is greater than A, get new A if ( startB >= limitA ) { needA = true ; needB = false ; continue ; } // if B is wholy contained in A, then get a new B if ( startB >= startA && limitB <= limitA ) { needA = false ; needB = true ; continue ; } // all other combinations mean we fail return false ; } if ( ! strings . containsAll ( b . strings ) ) return false ; return true ; }
Returns true if this set contains all the characters and strings of the given set .