| 574 | |
| 575 | template <class TComparer> |
| 576 | inline void QuickSort(TComparer&& comparer) { |
| 577 | if (Begin() == End() || ++Begin() == End()) { |
| 578 | return; |
| 579 | } |
| 580 | |
| 581 | T* const pivot = PopFront(); |
| 582 | TIntrusiveList bigger; |
| 583 | TIterator i = Begin(); |
| 584 | |
| 585 | while (i != End()) { |
| 586 | if (comparer(*pivot, *i)) { |
| 587 | bigger.PushBack(&*i++); |
| 588 | } else { |
| 589 | ++i; |
| 590 | } |
| 591 | } |
| 592 | |
| 593 | this->QuickSort(comparer); |
| 594 | bigger.QuickSort(comparer); |
| 595 | |
| 596 | PushBack(pivot); |
| 597 | Append(bigger); |
| 598 | } |
| 599 | |
| 600 | private: |
| 601 | inline TIntrusiveList(const TIntrusiveList&) = delete; |