From fb63e5155be515ce37ef24abd9560cd5ab8fca34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=93=E8=88=AA?= <1210603696@qq.com> Date: Tue, 14 Oct 2014 16:48:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90sort=5Fheap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TinySTL/Algorithm.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/TinySTL/Algorithm.h b/TinySTL/Algorithm.h index 858dc10..b2c71ec 100644 --- a/TinySTL/Algorithm.h +++ b/TinySTL/Algorithm.h @@ -144,9 +144,16 @@ namespace TinySTL{ } //********* [sort_heap] *************** template - void sort_heap(RandomAccessIterator first, RandomAccessIterator last); + void sort_heap(RandomAccessIterator first, RandomAccessIterator last){ + return TinySTL::sort_heap(first, last, + TinySTL::less::value_type>()); + } template - void sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp); + void sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp){ + for (auto cur = last; cur != first; --cur){ + TinySTL::pop_heap(first, cur, comp); + } + } //********* [is_heap] *************** template bool is_heap(RandomAccessIterator first, RandomAccessIterator last){