I have a algorithm which does bin packing based on certain conditions. I find that the flow of the algorithm is little bit complex for the readers to understand.
Below you can find the developed Java code. Is there a much simplified alternative flow for this code?
void binpack() {
boolean set=false, cmap=false;
while(set==false) {
set=true;
cmap=false;
pack[k.cnt]=new bins(k.lim, k.ptim);
for(int i=0;i<tot;i++) {
int s1,s2;
if(jm[i][1]==0) {
s1=jm[i][0];
set=false;
else if(pack[k.cnt].pushk<k.lim) {
for(int j=0;j<pack[k.cnt].pushk;j++) {
s2=pack[k.cnt].binjm[j][0];
for (Iterator<Integer> g= list[s1].iterator(); g.hasNext();) {
}
}
Notes:
ptim–>present time
etim–>end time
lim–>limit
A couple of things off the top of my head:
ptim,chk())if ( bool == false )should beif ( !bool )ifs orwhiles, use proper{}blocks.breakto a label.