Code from stl_algo.h
/// This is a helper function for the sort routine.
02243 template<typename _RandomAccessIterator, typename _Size>
02244 void
02245 __introsort_loop(_RandomAccessIterator __first,
02246 _RandomAccessIterator __last,
02247 _Size __depth_limit)
02248 {
02249 typedef typename iterator_traits<_RandomAccessIterator>::value_type
02250 _ValueType;
02251
02252 while (__last - __first > int(_S_threshold))
02253 {
02254 if (__depth_limit == 0)
02255 {
02256 _GLIBCXX_STD_P::partial_sort(__first, __last, __last);
02257 return;
02258 }
02259 --__depth_limit;
02260 _RandomAccessIterator __cut =
02261 std::__unguarded_partition(__first, __last,
02262 _ValueType(std::__median(*__first,
02263 *(__first
02264 + (__last
02265 - __first)
02266 / 2),
02267 *(__last
02268 - 1))));
02269 std::__introsort_loop(__cut, __last, __depth_limit);
02270 __last = __cut;
02271 }
02272 }
02273
Yong