public boolean sizeBiggerThan24 ( ) { int currentSize = 0 ; for ( int i = 0 ; i < elements . length ; i ++ ) { Object elem = elements [ i ] ; if ( elem == null ) { // Empty cell continue ; } else if ( elem instanceof ArraySet ) { // Don't reorg till the ArraySet reduces to Set24 return true ; } else if ( elem instanceof SetMax ) { // Don't reorg till the SetMax reduces to Set24 return true ; } else { currentSize += CompactSet . size ( elem ) ; } if ( currentSize > 24 ) { return true ; } } return false ; }
This method goes over the elements to see if this compact set can be fit inside a Set24