| 110 | /// Standard partitioning |
| 111 | template<class Type, class Less> |
| 112 | forceinline Type* |
| 113 | partition(Type* l, Type* r, Less &less) { |
| 114 | Type* i = l-1; |
| 115 | Type* j = r; |
| 116 | Type v = *r; |
| 117 | while (true) { |
| 118 | while (less(*(++i),v)) {} |
| 119 | while (less(v,*(--j))) if (j == l) break; |
| 120 | if (i >= j) break; |
| 121 | std::swap(*i,*j); |
| 122 | } |
| 123 | std::swap(*i,*r); |
| 124 | return i; |
| 125 | } |
| 126 | |
| 127 | /// Standard quick sort |
| 128 | template<class Type, class Less> |