package steptest; import java.awt.*; /** *

タイトル:

*

説明:

*

著作権: Copyright (c) 2003

*

会社名:

* @author 未入力 * @version 1.0 */ public class proc extends Thread{ waitButton wb; Applet1 aplt=new Applet1(); int data[]=new int[100]; int datac[]=new int[100]; String st; boolean stepF; Integer dummy=new Integer(1); public boolean stopF=false; public proc() { } public proc(Applet1 ap) { aplt=ap; } public void run(){ for(int i=0;i<=15;i++){ data[i]=(int)(Math.random()*100); } QuickSort(0,15); //task end aplt.alive=false; System.out.println("run:end"); aplt.exec.setLabel("exec"); aplt.stepButton.setEnabled(false); } void QuickSort(int left,int right) { int center,w,i,j; if(stopF) return; //System.out.println("QuickSort:"+left+","+right); printdata(data,left,right,-1,-1); aplt.textField2.setText(st); center=data[(left+right)/2]; i=left;j=right; do{ while(data[i] < center) i++; while(data[j] > center) j--; if( i<=j ){ //TRACE("change %d %d \n",data[i],data[j]); w=data[i];data[i]=data[j];data[j]=w; i++;j--; //m_chg++; } } while(i<=j); printdata(data,left,j,i,right); aplt.textField1.setText(st); if(!stopF) waitButton(); if (j>left) QuickSort(left,j); if(i=right) i=right=-1; //System.out.println("print:"+left+" "+j+" "+i+" "+right); for(int k=0;k<=15;k++){ if(k==left) st+="<"; if(k==i) st+="<"; st+=Integer.toString(data[k])+" "; if(k==j) st+=">"; if(k==right) st+=">"; } //aplt.textField1.setText(st); } synchronized public void waitButton(){ try{ wait(); }catch( InterruptedException e){} } synchronized public void step(){ notify(); } public void stopproc(){ stopF=true; } }//class