home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / diverses / leda / prog / basic / int_orde.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-15  |  478 b   |  39 lines

  1. #include <LEDA/dictionary.h>
  2. #include <LEDA/list.h>
  3.  
  4. int cmp(int x, int y) { return y-x; }
  5.  
  6. declare(INT,cmp)
  7.  
  8. declare2(dictionary,INT(cmp),int)
  9.  
  10. declare(list,INT(cmp))
  11.  
  12. main()
  13. {  
  14.    dictionary(INT(cmp),int) D;
  15.    list(INT(cmp)) L;
  16.    dic_item it;
  17.  
  18.    L.read("L = ");
  19.    L.print();
  20.    newline;
  21.  
  22.    INT(cmp) x;
  23.  
  24.    forall(x,L) 
  25.    { cout << x << " ";
  26.      D.insert(x,x);
  27.     }
  28.    newline;
  29.  
  30.    L.clear();
  31.  
  32.    forall_items(it,D) L.append(D.key(it));
  33.  
  34.    newline;
  35.  
  36.    L.print();
  37.  
  38. }
  39.