private static int [ ] getComplement ( int [ ] subset , int [ ] fullset ) { int size = fullset . length - subset . length ; // Returns null if no complement if ( size < 1 ) { return null ; } // Otherwsise define combination array and determine complement int [ ] complement = new int [ size ] ; int index = 0 ; for ( int i = 0 ; i < fullset . length ; i ++ ) { int item = fullset [ i ] ; boolean member = false ; for ( int j = 0 ; j < subset . length ; j ++ ) { if ( item == subset [ j ] ) { member = true ; break ; } } if ( ! member ) { complement [ index ++ ] = item ; } } return complement ; }
Returns the complement of subset .