void bubblePassL(Config &config,SiftMatrix &matrix,Rank *r,Switchable &switchable,Compare &compare) { NodeV::reverse_iterator ri; for(ri = r->order.rbegin(); ri<r->order.rend()-1; ++ri) { if(!compare.comparable(*ri)) continue; for(NodeV::reverse_iterator li = ri+1;li!=r->order.rend(); ++li) if(!switchable.canSwitch(*li,*ri)) break; else if(compare.comparable(*li)) { if(compare.shouldSwitch(*li,*ri)) { moveBefore(config,matrix,*ri,*li); ri = li-1; } break; } } }
void bubblePassR(Config &config,SiftMatrix &matrix,Rank *r,Switchable &switchable,Compare &compare) { NodeV::iterator li; for(li = r->order.begin(); li<r->order.end()-1; ++li) { if(!compare.comparable(*li)) continue; // search to right: if you find something you can't switch, go on to next li // if you find something to switch, jump to place it's been put for(NodeV::iterator ri = li+1;ri!=r->order.end(); ++ri) if(!switchable.canSwitch(*li,*ri)) break; else if(compare.comparable(*ri)) { if(compare.shouldSwitch(*li,*ri)) { moveBefore(config,matrix,*li,(ri==r->order.end()-1)?0:*(ri+1)); li = ri; } break; } } }