|   Softwaredesign: Beispiel: Sortieren eines Feldes |  | 
| abstract public class Array {   protected   int [] a;   public   void sortBy(CompareFunction c) {     // simple bubble sort     // --> 2 nested loops     for (int i = a.length -1;          i >= 0;          --i ) {       for (int j = 0;            j < i;            ++j ) {         if ( c.compare(a[j], a[j+1]) > 0 ) {           int tmp = a[j];           a[j]    = a[j+1];           a[j+1]  = tmp;         }       }     }   } } | 
| Letzte Änderung: 13.04.2012 | © Prof. Dr. Uwe Schmidt  |