private void sortPockets ( ) { // logger.debug(" SORT POCKETS Start#:" + pockets.size()); Hashtable < Integer , List < Integer > > hashPockets = new Hashtable < Integer , List < Integer > > ( ) ; List < Point3d > pocket ; List < List < Point3d > > sortPockets = new ArrayList < List < Point3d > > ( pockets . size ( ) ) ; for ( int i = 0 ; i < pockets . size ( ) ; i ++ ) { pocket = pockets . get ( i ) ; if ( hashPockets . containsKey ( Integer . valueOf ( pocket . size ( ) ) ) ) { List < Integer > tmp = hashPockets . get ( Integer . valueOf ( pocket . size ( ) ) ) ; tmp . add ( i ) ; hashPockets . put ( pocket . size ( ) , tmp ) ; } else { List < Integer > value = new ArrayList < Integer > ( ) ; value . add ( i ) ; hashPockets . put ( pocket . size ( ) , value ) ; } } List < Integer > keys = new ArrayList < Integer > ( hashPockets . keySet ( ) ) ; Collections . sort ( keys ) ; for ( int i = keys . size ( ) - 1 ; i >= 0 ; i -- ) { List < Integer > value = hashPockets . get ( keys . get ( i ) ) ; // logger.debug("key:" + i + " Value" + keys.get(i) // + " #Pockets:" + value.size()); for ( int j = 0 ; j < value . size ( ) ; j ++ ) { sortPockets . add ( pockets . get ( value . get ( j ) ) ) ; } } // logger.debug(" SORT POCKETS End#:" + sortPockets.size()); pockets = sortPockets ; }
Method sorts the pockets due to its size . The biggest pocket is the first .