private void minimize ( ) { // Algorithm: compare each entry n to all subsequent entries in // the list: if any subsequent entry matches or widens entry n, // remove entry n. If any subsequent entries narrow entry n, remove // the subsequent entries. for ( int i = 0 ; i < size ( ) ; i ++ ) { GeneralNameInterface current = getGeneralNameInterface ( i ) ; boolean remove1 = false ; /* compare current to subsequent elements */ for ( int j = i + 1 ; j < size ( ) ; j ++ ) { GeneralNameInterface subsequent = getGeneralNameInterface ( j ) ; switch ( current . constrains ( subsequent ) ) { case GeneralNameInterface . NAME_DIFF_TYPE : /* not comparable; different name types; keep checking */ continue ; case GeneralNameInterface . NAME_MATCH : /* delete one of the duplicates */ remove1 = true ; break ; case GeneralNameInterface . NAME_NARROWS : /* subsequent narrows current */ /* remove narrower name (subsequent) */ remove ( j ) ; j -- ; /* continue check with new subsequent */ continue ; case GeneralNameInterface . NAME_WIDENS : /* subsequent widens current */ /* remove narrower name current */ remove1 = true ; break ; case GeneralNameInterface . NAME_SAME_TYPE : /* keep both for now; keep checking */ continue ; } break ; } /* end of this pass of subsequent elements */ if ( remove1 ) { remove ( i ) ; i -- ; /* check the new i value */ } } }
minimize this GeneralSubtrees by removing all redundant entries . Internal method used by intersect and reduce .