SelectionSort.java

Go to the documentation of this file.
00001 
00012 package sorting;
00013 
00014 import java.awt.*;
00015 
00022 public class SelectionSort extends Sort
00023 {
00024 
00030   protected void doSort()
00031   {
00032     for (int index=0; index<theArray.length-1; index++)
00033     {
00034       int minIdx = minimum(theArray, index, theArray.length-1);
00035       this.exchange(theArray, index, minIdx);
00036       this.showArray();
00037       this.theLabel.setText(this.calcRuntime()+"ms");
00038       this.theLabel.validate();
00039     }
00040   }
00041 
00045   private int minimum(int[] array, int anfang, int ende)
00046   {
00047     int minIdx = anfang;
00048     for (int index=anfang+1; index<=ende; index++)
00049     {
00050       if (array[index] < array[minIdx])
00051       {
00052         minIdx = index;
00053       }
00054     }
00055     return minIdx;
00056   }
00057 
00058 }

Generated on Thu Jun 22 19:07:31 2006 for Doxygen Example (Java) by  doxygen 1.4.5