Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. #ifndef _ALGORITHM_INCLUDED
  2. #define _ALGORITHM_INCLUDED
  3. #include <vector>
  4. #include <stdlib.h>
  5. namespace std
  6. {
  7.   static bool (*__cmpfn)(const void* elem1, const void* elem2);
  8.   static int __compare(const void* elem1, const void* elem2)
  9.   {return __cmpfn(elem1,elem2)?-1:1;}
  10.   template<class T, class Pred>
  11.     void sort(T* first, T* last, Pred pr)
  12.   {
  13.     __cmpfn=(bool(*)(const void*,const void*))pr;
  14.     qsort(first,last-first,sizeof(*first),&__compare);
  15.   }
  16. }
  17. #endif
  18.